Barbara, you are right! This happens if you only reade half of the post.
I just corrected my solutions
Announcement
Collapse
No announcement yet.
get first day of month and first day of prev month
Collapse
X
-
Birgitta, your code only gets the first day of the current month. The requirement is to get the first day of the previous month if today is the first day of the month.
I think a good way to solve this is to start by subtracting 1 day from the given date. So instead of working on 2020-04-02 and 2020-04-1, your code would work on 2020-04-01 and 2020-03-31. Then, find the first day of the month for that new date.
This is your first SQL statement with the red part added.
Code:Exec SQL Set :FirstDay = Last_Day(:HostDate [COLOR=#FF0000][B]- 1 day[/B][/COLOR] - 1 Month) + 1 day;
Leave a comment:
-
Your version will work but given you second requirement I'd do it this way:
Code:dayNum = %subdt( todayDate); If dayNum = 1; firstDay = todayDate - %Months(1); Else; firstDay = todayDate - %Days(dayNum - 1); EndIf;
Leave a comment:
-
get first day of month and first day of prev month
I'm sure this is on here somewhere I just cant find it, I need to get first day of month which I think is firstDay = todayDate - %Days(%subdt( todayDate:*days)-1);
but if today is the first of month I need to get the prev month first day of month, the job I'm running uses previous day for its updates
Leave a comment: