负责sql-查询表中日期字段存储的数据与当下日期相差天数(分为7天之内跟七天之后)

代码如下:
SELECT
    br.reminderDate,
    br.flag,
    br.id,
    br.lunarBirthday,
    br.solarBirthday,
    CASE
WHEN DATEDIFF(DAY, GETDATE(), reminderDate) > 0
AND DATEDIFF(DAY, GETDATE(), reminderDate) < 7 THEN
    DATEDIFF(DAY, GETDATE(), reminderDate)
ELSE
    DATEDIFF(DAY, GETDATE(), reminderDate)
END days
FROM
    BirthdayReminder br
WHERE
    br.usersid =63
AND br.CompanyInfoId =23
ORDER BY
    days

你可能感兴趣的:(负责sql-查询表中日期字段存储的数据与当下日期相差天数(分为7天之内跟七天之后))