如何将日期更改为毫秒ms sql server(How to change date to milliseconds ms sql server)

编程入门 行业动态 更新时间:2024-10-28 06:32:55
如何将日期更改为毫秒ms sql server(How to change date to milliseconds ms sql server)

我正在尝试将ms sql server中的日期类型转换为毫秒,这是我尝试过的。 我是ms sql server的新手,非常感谢someones的帮助。

SELECT datediff(ms,date(),a.ReportDate), a.Peak from [RealTimeUsage] a where exists( select top 10 * from CustomerPortal.dbo.users b, CustomerPortal.dbo.UsersDevice c where (b.useridid = c.useridid) order by a.ReportDate )

I'm trying to convert a date type in ms sql server to milliseconds here's what I've tried. I'm totally new to ms sql server and would appreciate someones help.

SELECT datediff(ms,date(),a.ReportDate), a.Peak from [RealTimeUsage] a where exists( select top 10 * from CustomerPortal.dbo.users b, CustomerPortal.dbo.UsersDevice c where (b.useridid = c.useridid) order by a.ReportDate )

最满意答案

sql-server中没有构建函数date()。 如果您想要当前日期,请尝试使用getdate()函数

SELECT datediff(ms,getdate(),a.ReportDate),a.Peak FROM [RealTimeUsage] a 在哪里( 选择TOP 10 * FROM CustomerPortal.dbo.users b,CustomerPortal.dbo.UsersDevice c WHERE(b.useridid = c.useridid)ORDER BY a.ReportDate )

和DATEDIFF()语法是DATEDIFF(datepart,startdate,enddate)enddate将是第三个参数,startdate将是第二个(如果你错误地给出了它)

There is no built function date() in sql-server. If you want the current date, try using getdate() function

SELECT datediff(ms,getdate(),a.ReportDate), a.Peak FROM [RealTimeUsage] a WHERE EXISTS( SELECT TOP 10 * FROM CustomerPortal.dbo.users b, CustomerPortal.dbo.UsersDevice c WHERE (b.useridid = c.useridid) ORDER BY a.ReportDate )

and DATEDIFF() syntax is DATEDIFF ( datepart , startdate , enddate ) enddate would be third parameter and startdate would be second (In case you have given it by mistake)

更多推荐

本文发布于:2023-08-07 19:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465680.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   日期   ms   sql   milliseconds

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!