在我的搜索引擎上,我看到了多个结果来获得一个月的第一天,但我想做一些稍微不同的事情。在 SQL 2016 中,我想检查今天GetDate()是否是该月的第一天。
我该怎么做?
IF DAY(GetDate()) = 1
print 'first of the month'
ELSE
print 'not first of the month'
Run Code Online (Sandbox Code Playgroud)
或者
IF DATEPART(DAY, GETDATE()) = 1
print 'first of the month'
ELSE
print 'not first of the month'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45 次 |
| 最近记录: |