Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1

Thread: datediff issue

  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    datediff issue

    Code:
    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
    http://dev.mysql.com/doc/refman/5.0/...functions.html

    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:
    Code:
    SELECT TO_DAYS(current_timestamp()) - TO_DAYS(dateuploaded) FROM images WHERE id=4
    Is this the fastest/easiest way to do it?
    Last edited by thesavior; 01-19-2007 at 09:17 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •