SQL SERVER DATETIME应用
时间:2021-07-01 10:21:17
帮助过:15人阅读
‘上周的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(WEEK,
DATEDIFF(WEEK,
0,
GETDATE())
-1,
0),
120);
PRINT ‘本周的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(WEEK,
DATEDIFF(WEEK,
0,
GETDATE()),
0),
120);
PRINT ‘上月的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(
MONTH,
DATEDIFF(
MONTH,
0,
GETDATE())
-1,
0),
120);
PRINT ‘本月的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(
MONTH,
DATEDIFF(
MONTH,
0,
GETDATE()),
0),
120);
PRINT ‘上年的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(
YEAR,
DATEDIFF(
YEAR,
0,
GETDATE())
-1,
0),
120);
PRINT ‘本年的第一天:‘+CONVERT(
NVARCHAR(
20),
DATEADD(
YEAR,
DATEDIFF(
YEAR,
0,
GETDATE()),
0),
120);
How to get first and last day of previous month (with timestamp) in SQL Server
SQL SERVER DATETIME应用
标签:first mon convert overflow mes flow question over varchar