【问题标题】:Does anyone know how to insert a year value into a date so the day and month stay the same有谁知道如何将年份值插入日期以使日期和月份保持不变
【发布时间】:2020-06-29 13:37:27
【问题描述】:

您好,我正在尝试创建一个到期日期系统

我一直使用的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 年?

【问题讨论】:

  • 2 月 29 日你会做什么?
  • 请下定决心。 1:如何在日期中插入年份值,使日期和月份保持不变,2:以 4 周为周期显示作品,3:更新仅从当年到当年
  • expires >= #1/1/2020# and expires >=#28/1/2020# 等同于expires >=#28/1/2020# 或者你想要别的东西?

标签: sql database date datetime ms-access


【解决方案1】:

您可以使用DateSerial 构造一个日期,并使用Year(Date()) 获取当前年份,例如

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-25
    • 1970-01-01
    • 2018-12-24
    • 2021-12-26
    • 1970-01-01
    • 2021-12-16
    • 2020-01-24
    相关资源
    最近更新 更多