SQL 服务器中的 DATEDIFF
DATEDIFF in SQL Server
我正在使用 DATEDIFF
,但是,我得到了意想不到的结果。
我试图通过计算的 deadline
列中的 minus 5 days
来计算 Reminder
列。
我收到了一些结果,但它们没有意义。
下面是我的查询:
SELECT n.LastReceiptDate,
DATEADD(dd, 10, n.LastReceiptDate) AS deadline,
DATEDIFF(dd, 5, DATEADD(dd, 10, n.LastReceiptDate)) AS Reminder
FROM Table n;
SELECT n.LastReceiptDate,
DATEADD(dd, 10, n.LastReceiptDate) AS deadline,
DATEADD(dd, -5, DATEADD(dd, 10, n.LastReceiptDate)) AS Reminder
FROM Table n;
我正在使用 DATEDIFF
,但是,我得到了意想不到的结果。
我试图通过计算的 deadline
列中的 minus 5 days
来计算 Reminder
列。
我收到了一些结果,但它们没有意义。
下面是我的查询:
SELECT n.LastReceiptDate,
DATEADD(dd, 10, n.LastReceiptDate) AS deadline,
DATEDIFF(dd, 5, DATEADD(dd, 10, n.LastReceiptDate)) AS Reminder
FROM Table n;
SELECT n.LastReceiptDate,
DATEADD(dd, 10, n.LastReceiptDate) AS deadline,
DATEADD(dd, -5, DATEADD(dd, 10, n.LastReceiptDate)) AS Reminder
FROM Table n;