SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is this valid sql?

    I'm using the following WHERE statement in a web page that's accessing a postgres 8 database.

    WHERE
    (Now()<tbl37.col6)

    tbl37.col6 is a date field. Is this proper syntax for comparing a date field to today's date?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    WHERE current_date < tbl37.col6

  3. #3
    SitePoint Guru
    Join Date
    Aug 2003
    Location
    CT
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    depends on the sql server.

    above is for mysql (maybe others).
    mssql server, you'd want to use

    WHERE getdate() < tbl37.col6

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,021
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    actually, both NOW() and GETDATE() include the time, whereas CURRENT_DATE doesn't, and that makes more sense to me in the given context

    yes, johnjohn2, postgresql supports CURRENT_DATE
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •