tags:

views:

102

answers:

6

Hello, I dont know if this is possible. I have researched it and cant find anything. I want to add 6 hours onto the value now() will return. At the moment it comes back in a datetime format in the database.

Is there another function where i can add 6 hours onto the current time? Thankyou

+4  A: 

Use NOW() + INTERVAL 6 HOUR. As an example:

SELECT NOW(), NOW() + INTERVAL 6 HOUR

Result:

'2010-07-16 21:25:17', '2010-07-17 03:25:17'
Mark Byers
+2  A: 

Use the DATE_ADD function:

SELECT DATE_ADD(NOW(), INTERVAL 6 HOUR)
OMG Ponies
+1  A: 

I think you want DateAdd - see here.

Will A
+2  A: 

DATE_ADD(NOW(), INTERVAL 6 HOUR)

Phil
+3  A: 

You could use DATE_ADD:

SELECT DATE_ADD(now(), INTERVAL 6 HOUR);
Justin Ethier
A: 

I'm always forgetting the correct syntax for this, so I find this page of the mysql doc to be a good bookmark:

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

It's complete with examples like those that others posted