Skip to main content
Nintex Community Menu Bar

Date calculation for the days of last month

  • May 11, 2018
  • 3 replies
  • 138 views
  • Translate

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?

Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+14
  • Scholar
  • 4681 replies
  • May 13, 2018

use convert value action

Translate

Forum|alt.badge.img+5
  • 53 replies
  • May 23, 2018

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

Translate

Forum|alt.badge.img+6
  • 60 replies
  • February 9, 2021

Maybe this will help, as I needed to calculate a due date on a form to be the last day of the current month. This is the formula I used, which maybe you can adapt to meet your requirements:

 

dateAdd("days",
dateDiff("TotalDays",dateNow(),date(
convertToNumber(formatDate(dateNow(),"YYYY")),
sum(convertToNumber(formatDate(dateNow(),"M"))+1)
,1)),
dateNow())

 

What the above does is find the number of days between the current date and the first day of the next month, and then adds the number days to the current date.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings