簡體   English   中英

有誰知道如何在日期中插入年份值,以便日期和月份保持不變

[英]Does anyone know how to insert a year value into a date so the day and month stay the same

嗨,我正在嘗試創建一個日期到期系統

我一直在使用的 SQL 是:

SELECT client,make, model,units, expires AS [last checked], dateadd("d",168'[expires]) AS [dates due]
FROM [ServicingDetails]
WHERE expires >= #1/1/2020# and expires >=#28/1/2020#

我如何讓 2020 年每年更新到 2021 年?

您可以使用DateSerial構建日期,並使用Year(Date())獲取當前年份,例如

WHERE expires >= DateSerial(Year(Date()), 1,1) and expires >= DateSerial(Year(Date()), 1, 28)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM