cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Date calculation for the days of last month

I am trying to create a site workflow that runs at the beginning of each month that looks at a list and counts the entries for the previous month.

I created the logic to figure out the numbers for the month number of the last month, the year of last month (January would be year - 1) and the end day of last month depending on the month. My goal was to use these numbers to create a start date (mm/01/yyy) and end date (mm/dd/yyyy) but I can't seem to figure out how to create a date from those numbers. Setting them as a variable date doesn't work, calculate date doesn't work because you would have to have 0/00/0000 which it sees as blank. 

If I run it on the first of each month I could get the begin date by the current date - one month and the end date by subtracting one day from the beginning of the month. But, I want to be able to run this say on the 2nd or 3rd of the month manually if need be also, which wouldn't work.

Anyone able to suggest the best way to go about this?

Labels: (1)
0 Kudos
Reply
2 Replies
Workflow Hero

Re: Date calculation for the days of last month

use convert value action

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Date calculation for the days of last month

You can calculate the last day of the month by subtracting 1 day from the first of next month

The first of next month is found by

Get the day of the YourDate - fn-formatdate(YourDate ,dd) into ThisDay

calculate 1- ThisDay

Add this value (in days) to the YourDate to get FirstOfThisMonth

Add 1 month to this date

Now subtract 1 day from that result

0 Kudos
Accept as Solution Reply