Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Date/scripting issue

Featured Replies

So,

I have a script that finds all of the invoices for last month that meet certain criteria. To make the script work every month with no user interaction, in my script, I have a step that does a set field of:

Month(Get(CurrentDate)) -1

For example, if I do that find in September, I would get 8/*/06 in my date field. This works for every month but January.

When I do that I get a 500 error - it seems to treat it as an invalid date.

I would have thought that this would work. Is this a bug, or is this behavior by design?

any thoughts on the easiest way around this either way?

Try this in your set field script:

Let(cd = Get(CurrentDate); Date(Month(cd)-1; 1; Year(cd)) & "..." & Date(Month(cd); 0; Year(cd)))

  • Author

Cool, thanks for the tip, I will actually use that.

I guess I am still curious if there is a reason that the:

month(get(currentdate)) - 1

errors though, if that works. Especially if in you solution, it seems like you are doing the same thing.. just a little more drawn out.

Am I missing something with the date functions?

If you have a month of 1 and you subtract 1, what does that come out to be?

1-1 = 0. There is no month 0. The proper way to get the previous month would be to

Date(Month(Get(CurrentDate))-1; Day (Get(CurrentDate)); Year(Get(CurrentDate))

As for more information on how dates work, rather than me typing it all out, this post may provide some light.

Date Discussion

Another option would be to use:

Mod ( Month ( Get ( CurrentDate ) ) - 2 ; 12 ) + 1

instead of:

Month ( Get ( Currentdate ) ) - 1

This would fold back to December when CurrentDate is in January, just like the Date() function does.

However, John's suggestion is better practice, since it does not depend on file/system date settings.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.