Wondering if you can help a little with the syntax here. Trying to set a variable as a month value dependent upon whether it is past the 25th day of the month.
If it is, then it uses the current month (e.g. the variable 'month' will be 10 if the date is 28th October, but will be 9 if it's the 24th October). So far I've got the following:
select a
case
when (SELECT DAY(GETDATE()) >= 25
then a = (SELECT MONTH(GETDATE()))
else a = (SELECT MONTH(GETDATE()) - 1)
end
I understand you can't use less than or greater than signs, as case statements are only for evaluations (=)? Can anyone suggest another way of doing this?
Thanks.
select @your_variable = case when DAY(GETDATE()) = 25
then MONTH(GETDATE())
else MONTH(GETDATE()) - 1
end