-4

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?

5
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'
2
  • all my time i've spent in management studio i never knew about the Day() function. I've learned something today, thank you Jan 28 at 17:18
  • 1
    @JamesMandatory Wait til you learn about the MONTH() function, you'll need a change of underwear... ;)
    – J.D.
    Jan 28 at 20:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.