[Prod Dt] in (DATEADD(month, -1, EOMONTH(getdate()))
This is returning the 1/28/2023 for me.
Not sure why.
[Prod Dt] in (DATEADD(month, -1, EOMONTH(getdate()))
This is returning the 1/28/2023 for me.
Not sure why.
If your goal was to get end of the month taking into account current date, try moving your EOMONTH function:
SELECT EOMONTH(getdate()); /* 2023-01-28 */
SELECT DATEADD(month, -1, EOMONTH(getdate())) /* 2023-02-28 */
SELECT EOMONTH(DATEADD(month, -1, getdate())) /* 2023-01-31 */
EOMONTH() has a month offset as the 2nd parameter:
SELECT EOMONTH(getdate(),-1)
SELECT EOMONTH(getdate(),0)
SELECT EOMONTH(getdate(),1)
Aye! @robert_volk has the right ticket.