Newbies RodneyR Posted August 20, 2007 Newbies Posted August 20, 2007 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
VICH Posted August 20, 2007 Posted August 20, 2007 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.
Søren Dyhr Posted August 20, 2007 Posted August 20, 2007 I would do it this way: MonthName(aDate - Day ( aDate )-1) --sd 1
Fitch Posted August 20, 2007 Posted August 20, 2007 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! 1
Fenton Posted August 20, 2007 Posted August 20, 2007 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) ) 1
Fitch Posted August 20, 2007 Posted August 20, 2007 Quick testing shows we can simplify Søren's formula to: MonthName( aDate - Day( aDate ) ) See what I posted above about day zero.
Newbies RodneyR Posted August 20, 2007 Author Newbies Posted August 20, 2007 : : : Thanks to all for the quick and helpful replies. It's working great now! Rodney
comment Posted August 20, 2007 Posted August 20, 2007 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. 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now