Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Location
    UK
    Posts
    10

    Question Unanswered: Yesterday's Date

    I'm trying to run a query which uses yesterday's date as a parameter.


    The query is running on data where the date format is yyyy-mm-dd and I was trying to use something like 'SELECT bla bla WHERE date = GETDATE()-1.

    However as GETDATE also return the time is been a bit awkward.

    Anyone got any bright ideas that would help?

    Cheer in advance

    Jay

  2. #2
    Join Date
    Aug 2003
    Location
    Stockholm, Sweden
    Posts
    4
    select DATEADD (dd, -1, GETDATE()) would help you out.

  3. #3
    Join Date
    Nov 2003
    Location
    UK
    Posts
    10

    Thumbs down

    Originally posted by Pedalen
    select DATEADD (dd, -1, GETDATE()) would help you out.
    Thanks for that but that does not address the probelm unfortunatley. I need to reformat the GETDATE() into a datetime format without the time and then use the value to compare against the values in the query which have the yyyy-mm-dd format.

    Keep em coming

  4. #4
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    select convert(varchar(10),DATEADD (dd, -1, GETDATE()),126)


    the varchar(10) will cut out the time !!!

  5. #5
    Join Date
    Nov 2003
    Location
    UK
    Posts
    10

    Cool

    Originally posted by Karolyn
    select convert(varchar(10),DATEADD (dd, -1, GETDATE()),126)


    the varchar(10) will cut out the time !!!
    Thxs Karolyn
    This has helped...yippee

    J

  6. #6
    Join Date
    Sep 2003
    Posts
    212
    simply do this:

    convert(char(10),getdate()-1,121)

Posting Permissions

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