August 20, 200718 yr 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
August 20, 200718 yr 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.
August 20, 200718 yr 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!
August 20, 200718 yr 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) )
August 20, 200718 yr Quick testing shows we can simplify Søren's formula to: MonthName( aDate - Day( aDate ) ) See what I posted above about day zero.
August 20, 200718 yr Author Newbies : : : Thanks to all for the quick and helpful replies. It's working great now! Rodney
August 20, 200718 yr 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