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

Create 'Age' field via Select

Status
Not open for further replies.

Shrum

Programmer
May 17, 2002
122
US
I am trying with MySQL 4.1.1 (alpha) to produce a 'Age' field like so:

select=TIMEDIFF(NOW(),`modified`) AS `age`,`name`,`caption`,`modified`

Currently, this works...it reports back the number of hours old the last modification took place.

I want to go a step further and have it report back *days* old. I tried using DATE_FORMAT() but that won't work. What do I need to use, in terms of a SQL function that will allow me to do this conversion?

TIA

=============================
Sean Shrum
Shrum Consulting
C.A.T.S.: Consulting: Programming: R/C Soaring:
 
select=TIMEDIFF(NOW(),`modified`)/24 AS `age`,`name`,`caption`,`modified`

perhaps an idea
 
Would you need to manipulate the date into epoch format (1 jan 1970) and work from there ?
 
Datediff() works perfectly...it takes the NOW() so I can now output the # of days since files/posts/etc were modified.

Thanks.

P.S. MySQL only supports this in 4.1.1 ALPHA currently but then again I was able to get my web host to install it for me :)

=============================
Sean Shrum
Shrum Consulting
C.A.T.S.: Consulting: Programming: R/C Soaring:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top