计算报告中的日期与服务器中的日期的差异

发布于 2025-01-05 17:42:22 字数 132 浏览 3 评论 0原文

我想计算我们系统生成的报告中两个日期之间的差异。 日期作为 sdCreateDate 存储在系统中,但我似乎无法使用 SELECT DateDiff(d,'sdCreateDate','GetDate()') 以显示差异。

I would like to calculate the difference between 2 dates from a report generated in our system.
The date is stored in the system as sdCreateDate, but I can't seem to use
SELECT DateDiff(d,'sdCreateDate','GetDate()') to get the difference displayed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初雪 2025-01-12 17:42:22
SELECT DateDiff(d, sdCreateDate, GetDate())

错误出在你的参数上。您不能在 sdCreateDategetdate() 上添加单引号。您需要字段名称和函数调用,而不是字符串文字。

DATEDIFF() MSDN 参考

SELECT DateDiff(d, sdCreateDate, GetDate())

The error was with your parameters. You can't put single quotes on sdCreateDate and getdate(). Instead of string literals, you need to have the field name and the function call.

DATEDIFF() MSDN Reference

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文