View Full Version : datediff issue

01-19-2007, 09:34 PM
SELECT DATEDIFF('dateuploaded',CURRENT_TIMESTAMP()) as date_diff FROM images WHERE id=4

Okay, on insertion, the column dateuploaded is the current timestamp. What I want to know, is how many days that row has existed, and be returned an integer. As far as I know, that is what Datediff does. I tried to figure this out from

but it didnt explain how to use a timestamp from a row. The example it gave is:

mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
-> 1
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
-> -31

Any ideas on how to make my process work?

The error I get is:

#1305 - FUNCTION imagecomp.DATEDIFF does not exist

Solution Possibility #1:

SELECT TO_DAYS(current_timestamp()) - TO_DAYS(dateuploaded) FROM images WHERE id=4

Is this the fastest/easiest way to do it?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum