Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use date_add in mysql, please help

Status
Not open for further replies.

owenewo

ISP
Oct 3, 2004
3
US
i know to use it like this:
SELECT DATE_ADD('1998-01-01 00:00:00', INTERVAL '1 10' DAY_HOUR)

then, it will add 1 day and 10 hours to the datetime.
but if I have a table called time with two fields, days and hours, how can i usr it?

does it look like this?

SELECT DATE_ADD('1998-01-01 00:00:00', INTERVAL 'days hours' DAY_HOUR) newdate from time;

Please help.
Thank you in advance.






 
try it in two steps, nested:
Code:
select date_add(
         date_add('1998-01-01 00:00:00'
                 , interval `days` day) 
               , interval `hours` hour) 
        as newdate 
  from `time`

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top