gpt4 book ai didi

mysql YearWeek() 不起作用

转载 作者:行者123 更新时间:2023-11-29 21:13:56 26 4
gpt4 key购买 nike

我正在尝试从数据库中获取本周内的所有数据..如果该周已经结束,我希望显示下周的数据而不显示上周的数据....

这是我的代码:我尝试使用YearWeek()

            Select
systemusers.FirstName,
systemusers.MiddleName,
systemusers.LastName,
temperaturelogs.DateTime,
Locations.Description,
temperaturelogs.UnitID,
temperaturelogs.Temperature,
temperaturelogs.Humidity
From temperaturelogs
Inner Join Locations
On temperaturelogs.LocationID = Locations.LocationID
Inner Join SystemUsers
On temperaturelogs.Encoder = systemusers.UserID
Where
YEARWEEK('3/21/2016') = YEARWEEK(NOW())
AND
temperaturelogs.Encoder = 2 Order By temperaturelogs.DateTime DESC

最佳答案

基于从周一中午 12:00 到周日晚上 11:59:59.999 的一周

Where YourColumn >= DATEADD(wk, DATEDIFF(wk, 0, GETDATE() -1), 0)

关于mysql YearWeek() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36121769/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com