Jump 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.

"Previous month" name

Featured Replies

  • Newbies

It seems like there would be a simple solution to this, but I haven't found it yet.

I'm setting up a report that needs to have the PREVIOUS month's name in the header. What calculation, based on the system date, will accomplish this?

I've tried the following:

[color:red]MonthName(Get(CurrentDate)) (the result is "August")

[color:red]MonthName(Month(Get(CurrentDate))-1) (the result is "January")

Any ideas?

Thanks,

Rodney

two options. set up the month(get(currentdate)-1) calc. but then have set it to some like

if(month(get(currentdate)-1)=1;"January";

if(month(get(currentdate)-1)=2;"Febuary";

if(month(get(currentdate)-1)=3;"March";..... so on and so forth....

but the last line would be

if(month(get(currentdate)-1)=0;"December";""))))))))))))

the second option would be

monthname("1/"& month(get(currentdate)-1) & "/" & year(get(currentdate))

both of those should work.

I would do it this way:

MonthName(aDate - Day ( aDate )-1)

--sd

let( [ now = Get ( CurrentDate ) ; 

        prev = Date ( month(now) - 1 ; day(now) ; year(now) ) ] ; 

MonthName ( prev )

)




Note that FileMaker does the math for you when for example it's January 2008, the "month - 1" part will evaluate to December. 



This means, for another example, that you could also write this: 


let( [ now = Get ( CurrentDate ) ; 

        prev = Date ( month(now)  ; 0 ; year(now) ) ] ; 

MonthName ( prev )

)

Kinda weird, kinda cool!

You've given it a number (7), when the function is MonthName ( date )

So, yeah, the month name of date 7 is January.

You could give it the last date of last month, which is 1 less than the 1st date of this month:

Let (

month_1st_day = Date ( Month ( Get ( CurrentDate)); 1 ; Year (Get (CurrentDate)) );

MonthName ( month_1st_day -1)

)

Quick testing shows we can simplify Søren's formula to:

MonthName( aDate - Day( aDate ) )

See what I posted above about day zero.

  • Author
  • Newbies

: : : Thanks to all for the quick and helpful replies. It's working great now!

Rodney

Actually, if you only need to DISPLAY the previous month's name, you could use just:

Get(CurrentDate) - Day ( Get(CurrentDate) )

Set the result type to Date, and format the field to show only the month name.

Create an account or sign in to comment

Important Information

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

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.