Jump to content

How do I find "current month"?


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

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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

This topic is 6205 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.