Re: Help with UPDATE query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux