Jump to content
Sign in to follow this  
Nishimark

How do I find "current month"?

Recommended Posts

Greetings. I would like to create a script that, among other things, displays all records for the current month, as well as another script that can display all records for the previous month and one for next month. I would like FM to determine the current month so that I don't have to manually enter it. I have a single date field that shows the date of an event. I would like to be able to make buttons for "This Month", "Last Month", and "Next Month" that will operate scripts to do those searches. Any ideas?

Share this post


Link to post
Share on other sites


Enter Find Mode[]

Set Field[ date ; Let( monthOffset = 0 ;

Date ( Month(Get(CurrentDate)) + monthOffset; 1 ; Year(Get(CurrentDate)) ) & "..." & Date( Month(Get(CurrentDate)) + 1 + monthOffset  ; 0 ; Year(Get(CurrentDate))) ) ]

Perform Find[]

Change MonthOffset accordingly... -1 will give you previous month + 1 will give you next month +2 the month after that, 0 will give the current month...

You may want to pass the value as a script parameter instead of hard coding it though.

Share this post


Link to post
Share on other sites

Sorry, but could you walk me through it a bit slower. Where and how do I enter the script that you noted in your previous e-mail? thanks.

Share this post


Link to post
Share on other sites

Hi Nishimark,

Go To Scripts -> ScriptMaker

Add a new script, call it "month_search"

Add the following steps from the left bar:

Enter Find Mode

Set Field

Perform Find

For the Enter Find Mode, uncheck "pause"

For Set Field, specify your target field to be whatever date field it is you are searching for

For the calculation specify the following:

Let( monthOffset = Get(ScriptParameter) ;

Date ( Month(Get(CurrentDate)) + monthOffset; 1 ; Year(Get(CurrentDate)) ) & "..." & Date( Month(Get(CurrentDate)) + 1 + monthOffset ; 0 ; Year(Get(CurrentDate))) )

Click Ok to save the script and Ok to exit ScriptMaker.

Now, enter layout mode, draw a shape or insert an image for your button. Right click the image / shape and choose button Setup. Choose perform script from the bar in the left and then click the specify button. Find the script you called "month_search" and down the bottom where it says "optional script parameter" enter the month offset i.e. -1 for the previous month, 1 for the next month, 0 for the current month etc.

Click OK and then try run the script.

Share this post


Link to post
Share on other sites

Glad to help ;)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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