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.

get current month in button bar calculation

Featured Replies

I'm trying to set up a button bar that displays the current months names based on the following

 

Current month

Last month

Next Month

 

I can use Month (Get(current date)) - 1 (for example) but I get a number of 2 for february or 1 for january

If I use Monthname (Get (Currentdate) - 1 my result is (-1)

Thanks in advance, thanks!

1 hour ago, Matthew R White said:

If I use Monthname (Get (Currentdate) - 1 my result is (-1)

If you subtract 1 from the current date, you get the date of yesterday, not a date in the previous month.
And if you subtract 1 from a month's name (text), then you get -1 (since text is evaluated as 0).

To calculate the name of the previous month, you can use =

MonthName ( Date ( Month ( Get ( CurrentDate ) ) - 1 ; 1 ; 2 ) )

 

 

Edited by comment

7 hours ago, comment said:

To calculate the name of the previous month, you can use =


MonthName ( Date ( Month ( Get ( CurrentDate ) ) - 1 ; 1 ; 2 ) )

 

Hi Michael!

Would you be so kind as to explain something for me?  Of course Get ( CurrentDate ) will never be empty, and since button bar is a layout object, it will always refresh that date (unlike a calculation field which must be checked as 'Do not store calculation results' when using Get ( CurrentDate ).  

My question ...  If I use a regular date field and if that date field is empty then it generates November.  I cannot spot the translation logic as to why!

Also, if regular date field is used as a calculation, it will not produce a result if your date field is empty because default is checked 'do not evaluate if all referenced fields are empty' so that is great.  But if regular date is used on button bar, it should be wrapped with an If() test to not display the result (or to display different default result) if empty because non-field calculations (button bar, script etc) can not take advantage of that 'do not evaluate' checkbox.

What fun! Thank you for always throwing surprises into the mix!  :smile3:

Is it as simple as Month 1 is January so Month 0 is December ... then previous month is November?

Edited by LaRetta

5 hours ago, LaRetta said:

Is it as simple as Month 1 is January so Month 0 is December ... then previous month is November?

Yes, it is. You can see that:

Date ( Month ( "" ) - 1 ; 1 ; 2 )

is Nov 1, 0001. Strictly speaking, Month ( "" ) is not 0, but empty - but when you subtract a number from it, it's as good as.

 

 

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.