Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6304 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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

Posted

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.

Posted

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!

  • Like 1
Posted

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)

)

  • Like 1
Posted

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

MonthName( aDate - Day( aDate ) )

See what I posted above about day zero.

Posted

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.

  • Like 1

This topic is 6304 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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