Re: Help with UPDATE query

From: Date: Tue, 30 Sep 2003 02:28:18 +0000
Subject: Re: Help with UPDATE query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-30760@lists.php.net to get a copy of this message
In article <20030929220030.2215.qmail@pb1.pair.com>, shaun@mania.plus.com says... > Hi, > > I have two columns in my Bookings table of type DATETIME - > Booking_Start_Date and Boking_End_Date. How can i update every row so that > all of the times for Booking_Start_Date are 09.00 and all of the times for > Booking_End_Date are 17.30, without affecting any of the dates? > > Thanks for your help > Off the top of my head - use mysql's DATE_FORMAT to build a date string, then concatenate the required time string and use that as the update value. Something like UPDATE table SET Booking_Start_date = CONCAT(DATE_FORMAT(Booking_Start_Date, your format here),'09.00'), Booking_End_date = CONCAT(DATE_FORMAT(Booking_End_Date, your format here),'17.30'); You'll need to play a bit with that - and of course test on a backup. Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet?

« previous php.db (#30760) next »