Page 1 of 1
Format DateDiff or TimeDiff [SOLVED]
Posted: Thu Feb 15, 2007 11:32 am
by GeXus
Does anyone know how to format datediff or timediff, I tried the following to format timediff, but it just returned null, which isnt accurate.
Code: Select all
SELECT content_id, DATEDIFF( created_dt, now( ) ) AS datediff, date_format( TIMEDIFF( created_dt, now( ) ) , '%H:%i' ) AS timediff
FROM content
Posted: Thu Feb 15, 2007 11:56 am
by Oren
Can you please be more specific about what your problem/question is?
Posted: Thu Feb 15, 2007 12:03 pm
by GeXus
I think i've got it... this ended up working for me
Code: Select all
SELECT content_id, DATEDIFF( created_dt, now( ) ) AS datediff, time_format( replace( TIMEDIFF( created_dt, now( ) ) , '-', '' ) , '%l' ) AS timediff
FROM content
The problem is that I want to display the following format '4 Days 3 Hours'. So I need to format the date and time appropriatly while using datediff, but the above worked.
Posted: Thu Feb 15, 2007 12:17 pm
by Oren
So the problem is solved? If so, please edit the post's title and change it from:
Format DateDiff or TimeDiff to:
Format DateDiff or TimeDiff [SOLVED] 