Get data between days

Hello, I need help please.

I have a startDate like 2022, 7, 12 and I want get second date adding 31 days on startDate to get 2022,8, 12

For exemple
first = system.date.getDate(2022, 7, 12)

second = system.date.getDate(2022,8, 12) #I want get this date

print system.date.daysBetween(first,second) #print 31


first = system.date.getDate(2022, 7, 17)
print first
second = system.date.addDays(first, 31)
print second

print system.date.daysBetween(first,second)

Thank you Sr

You may not be doing what I believe you are, but I thought it worth noting that there isn’t always ‘31’ days between the same day in different months.

If what you are really trying to do is move to the same day number in the next month, then you should use system.date.addMonths(first,1)

If that isn’t what you’re really looking for, then carry on.

1 Like