Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012

    Unanswered: Is it possible a "Yesterday Query"?

    Hi to All,

    colud SomeOne resolve this proble?

    I' m using a query to select the rows of yesterday in a tab.

    In order to this scope, I am usung a query like this:
     SELECT * 
    FROM my_tab
    WHERE year= extract(year from current date)
    AND month= extract(month from current date)
    AND day= extract(day from current_date)-1 ;
    The query is perfect for every day of month: infact, if the current_dat is 31-8-2017 the query will return all rows of 30-8-2017. And this resul is correct.
    But obviously it is not correct if the current day is the first day of a new month: infact, if the current_date is 01-09-2017 the query will search all rows of 0-9-2017. And this search is not correct.

    Tanks in advance.


  2. #2
    Join Date
    Aug 2017
    Provided Answers: 1
    To get yesterdays date you can:

    Select CURRENT_DATE + INTERVAL '-1 day';

  3. #3
    Join Date
    Dec 2012
    Hi Indiri,

    Your is a perfect solution.
    Many tanks, Indiri.


Posting Permissions

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