如何列出最近10天内的记录? [英] How to list records with date from the last 10 days?

查看:63
本文介绍了如何列出最近10天内的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT Table.date FROM Table WHERE date > current_date - 10;

在PostgreSQL上可以使用吗?

Does this work on PostgreSQL?

推荐答案

是的,这在PostgreSQL中确实有效(假设 date 列的数据类型为 date
为什么不尝试呢?

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

标准ANSI SQL格式为:

The standard ANSI SQL format would be:

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

我更喜欢这种格式,因为它使内容更易于阅读(但与<$ c相同$ c> current_date-10 )。

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

这篇关于如何列出最近10天内的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆