8 Replies Latest reply on Jul 28, 2014 11:54 AM by Hudi

# First Date of Previous Month

How would I find the first day of last month?

Many of the calculations I've seen on this (and other) forums show this:

Month ( Get(CurrentDate ) ) -1 & "/" & 1 & "/" & Year ( Get(CurrentDate ) )

Which makes sense but does not accomodate for the month of January because you would end up with 0/1/2014, when it should be 12/1/2013.

Thank you!

• ###### 1. Re: First Date of Previous Month

Date (Month (Get ( CurrentDate ) -1); 1; Year (Get ( CurrentDate )))

1 of 1 people found this helpful
• ###### 2. Re: First Date of Previous Month

Hudi, see dsvail's answer as correct. If you do it that way, FM will automatically subtract for the year, in the case of Jan. It looks like you were trying to make "text" and supplying the "/" separators. That won't subtract the year for you.

Beverly

1 of 1 people found this helpful
• ###### 3. Re: First Date of Previous Month

Thank you dsvail.

• ###### 4. Re: First Date of Previous Month

Aha. Thanks Beverly!

• ###### 5. Re: First Date of Previous Month

Slight Correction for future reference.

Date (Month (Get ( CurrentDate )) - 1; 1; Year (Get ( CurrentDate )))

• ###### 6. Re: First Date of Previous Month

Beverly Voth wrote:

Hudi, see dsvail's answer as correct. If you do it that way, FM will automatically subtract for the year, in the case of Jan. It looks like you were trying to make "text" and supplying the "/" separators. That won't subtract the year for you.

Beverly

No, dsvail's answer is not correct, and Hudi's correction is appropriate – which can easily be seen with better formatting:

dsvail's version:

Date (

Month (Get ( CurrentDate ) -1) ;

1;

Year (Get ( CurrentDate ))

)

where just the first line ( month argument) is

Month (

Get ( CurrentDate ) -1

)

which is the month of yesterday's date, not the last month (or if so, then only by accident).

Correct is

Month ( Get ( CurrentDate ) ) - 1

or in toto:

Let (

cd = Get ( CurrentDate ) ;

Date ( Month ( cd ) - 1 ; 1 ; Year ( cd ) )

)

• ###### 7. Re: First Date of Previous Month

I didn't look at the syntax, which I'm sure was just typing error. Had it been done in FM calc dialog, copied and pasted into the reply, I'm sure it would have been "more" correct. I was explaining that the use of the subtraction from month, when done in the Date() function, does account for losing a year as well.

I'm sure Hudi was intelligent enough to look at the actual function in the Help and thus got the syntax correct.

: )

• ###### 8. Re: First Date of Previous Month

That's exactly what I thought, just a typo. The idea was correct.

My mistake was not using the Date function.

Thank you all for your swift help.