我正在尝试将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)
更多推荐
发布评论