سؤال

On my search engine I have seen multiple results to get the first day of a month, but I want to do something slightly different. In SQL 2016, I want to check if Today GetDate() is the first day of the month.

How would I do that?

هل كانت مفيدة؟

المحلول

IF DAY(GetDate()) = 1
    print 'first of the month'
ELSE
    print 'not first of the month'

Or

IF DATEPART(DAY, GETDATE()) = 1
    print 'first of the month'
ELSE
    print 'not first of the month'
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top