SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    rotterdam
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    datetime/timestamp

    I have a database with adresses.
    Now I only want to show adresses a day after entry.
    I believe I have to use datetime or timestamp to make something like : show all the adresses with a day => the day of today.

    What is the difference between datetime and timestamp?

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    Michigan, USA
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, I am unfamiliar with datetime, but the timestamp is simply the time in seconds since the epoch (something like January 1st, 1969, though I can't remember exactly)

    What you are wanting to do can be done with timestamp. You simply need to subtract the proper number of seconds in a day (60 * 60 * 24) from the current time, and then any number that is less than that is eligible to be printed.

  3. #3
    SitePoint Member enjoy or die's Avatar
    Join Date
    Oct 2003
    Location
    the Internet
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't need the info about hours/minutes/seconds, it's probably easier to use DATE type, which stores only info about the date. And in your query you can use CURRENT_DATE function, something like this (assuming your field with DATE is named "day"):
    "select ... where day <= CURRENT_DATE"
    If i understood you correctly, and you want to get addresses that were inserted yesterday.


Bookmarks

Posting Permissions

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