How to list records with date from the last 10 days?

前端 未结 6 446
Happy的楠姐
Happy的楠姐 2020-12-13 01:36
SELECT Table.date FROM Table WHERE date > current_date - 10;

Does this work on PostgreSQL?

6条回答
  •  独厮守ぢ
    2020-12-13 02:29

    Yes this does work in PostgreSQL (assuming the column "date" is of datatype date) Why don't you just try it?

    The standard ANSI SQL format would be:

    SELECT Table.date 
    FROM Table 
    WHERE date > current_date - interval '10' day;
    

    I prefer that format as it makes things easier to read (but it is the same as current_date - 10).

提交回复
热议问题