Help with a constant in SOQL (Salesforce)
One more thing please,
How would I make the previous month dynamic?
Current Code:
Report_Month_Start_HARD = DATEADD(DAY,-31,cast(‘2022-11-01’ as date)),
Report_Month_End_HARD = DATEADD(DAY,-1,cast(‘2022-11-01’ as date))
That gives me a range of Saturday, October 01, 2022 12:00 AM to Monday, October 31, 2022 12:00 AM. (Prior month from current month.)
I tried the below
Report_Month_Start = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) – 31, 0),
Report_Month_End = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) – 1, 0),
But that gave me a 31 day window around today:
Thursday, October 13, 2022 12:00 AM to Saturday, November 12, 2022 12:00 AM
EDIT: I realize I could just use the same as I did before, with only -1…
WHERE WARRANTY_START_DATE >= DATEADD(month, DATEDIFF(month, 0, GETDATE()) – 1, 0)
AND WARRANTY_START_DATE < DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
Thanks,
Read more here: Source link