how to count age

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mobilaku
    New Member
    • Sep 2006
    • 2

    how to count age

    dear all,

    i'm a beginner on php and mysql.
    i have a problem to count age of my data.
    here is the example : i want t know how many days are my record in database. i mean i want to count a field ( date_in ) - date today ( or input date ) and the result is on days.

    pls help me.

    many thanks
    Anggi
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Something like


    SELECT TO_DAYS(NOW())-TO_DAYS(post-date) AS DaysSincePost From YourTable;

    Comment

    • rkagrawal
      New Member
      • Aug 2006
      • 13

      #3
      The solution given by Banfa will do the purpose.
      If you want to try something else , get the first time + date in seconds , second time + date in seconds . Get their difference in seconds and convert the seconds into days .

      I hope it helps someone.


      Rahul Agrawal
      Developer
      Web2003 Corporation
      www.web2003corp .com

      Comment

      • mobilaku
        New Member
        • Sep 2006
        • 2

        #4
        Originally posted by Banfa
        Something like


        SELECT TO_DAYS(NOW())-TO_DAYS(post-date) AS DaysSincePost From YourTable;
        thank you very much, it's worked.

        Comment

        Working...