Results 1 to 4 of 4

Thread: Current date in SQL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    476

    Current date in SQL

    Hi,

    I am trying to selecte records from a table and want to check if the date field has a value of todays date or not. I forgot how to tell SQL to check the field. I don't want to pass a date instead I want to use the keyword that I forgot. I think it is either CURRENT DATE or TODAY or something like that.

    SELECT * FROM Payments WHERE P_date = current date

    or

    SELECT * FROM Payments WHERE P_date = TODAY

    can someone please HELP?

    Thanks.

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Current date in SQL

    getdate()

    But I think you'll have to parse it, because the result is in milliseconds (if I remember correctly). If you don't your date will never be equal to getdate().

  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Current date in SQL

    SQL server: GetDate (date + time)
    MS Access: Date (date only)
    Oracle: sysdate (date + time)
    Frans

  4. #4
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Current date in SQL

    you could make current date a string and then assign the date() to it, then format() the date() to use date instead of date/time

    however, the string wont accept spaces either so maybe you should do current_date instead or CurrentDate.

Posting Permissions

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



Click Here to Expand Forum to Full Width