开发者

Need similar function of strtotime( "next monday" ) in SQL Server

开发者 https://www.devze.com 2023-03-01 13:31 出处:网络
I need similar function of strtotime( \"next monday\" ) in SQL Serv开发者_运维百科er.DateAdd(d, (8+@@DateFirst+DatePart(dw,GetDate()))%7, GetDate())

I need similar function of strtotime( "next monday" ) in SQL Serv开发者_运维百科er.


DateAdd(d, (8+@@DateFirst+DatePart(dw,GetDate()))%7, GetDate())

This gives you next Monday, at the current time-of-day; i.e. if you use it at 11:49 AM Wednesday, you'll get next Monday at 11:49 AM. If that's not what you want, look up functions DatePart, DateAdd, and DateDiff - you should be able to adjust it.

0

精彩评论

暂无评论...
验证码 换一张
取 消