如何 select 所有日期排除今天前 30 天

how to select all date exclude 30 days before today

SELECT * FROM table
WHERE INVOICE_DATE .....(30 days have passed since today).....

示例:

今天 = 2021-11-05

2021-11-04 非 select

2021-10-07 非 select

2021-10-04select

2021-09-27select

有效,当前日期减去 30 天

SELECT * FROM table
WHERE INVOICE_DATE < CURRENT_DATE() - INTERVAL 30 DAY

您可以使用 python 语言的 time 库来完成。 这是如何完成的示例。

首先,记录当前的日期和时间。

import time
# This will store current datetime in epoch
epoch = time.time()

然后我们导入另一个库,将纪元转换为人类可读的格式。

import datetime
# This will return a date and time of exactly 30 days before today
dateToSelect = datetime.datetime.fromtimestamp(int(epoch)-2592000)