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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Usage of date_sub command

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All,

I'm trying to substract one date in my database from another date. I know that you can do it in this type of format(mysql> SELECT DATE_SUB("1998-01-01 00:00:00",
INTERVAL "1 10" DAY_HOUR);). I got that from the mysql manual. My problem is that the values are not hardcoded in the coding but dynamically obtain from the database. I can't seem to get the right syntax for it to work.

Any suugestions/advice would be appreciated.

Star
 
are you saying you can't get the correct format when the date is optained from the database ? if so , try this.

mysql> SELECT
DATE_SUB(DATE_FORMAT(date_field,'what ever format'),
INTERVAL '1 10' DAY_HOUR)
FROM blaa ;

hope this helps devnull22

--
Apparently if you play the Windows NT CD backwards you hear satanic messages. If you think that's bad, play it forwards and it installs Windows NT !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top