Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to find range of dates

Featured Replies

Fm 12.

I’m trying to create a script that finds a range of records over a 30 day period. However, it gives the error “find criteria not valid”

Enter Browse Mode

Set Variable [ $EndDate; Value:Get(CurrentDate) ]

Set Variable [ $StartDate; Value:Get(CurrentDate)-30 ]

Go to Layout [ “Last 30 records” (Primary) ]

Perform Find [ Specified Find Requests: Find Records; Criteria: Primary::Date: “$EndDate&"..."&$StartDate” ] [ Restore ]

Any suggestions?

Try this instead:

Set Variable $StartDate; date(month($endDate);Day($endDate)-30;Year($enddate))

Set Variable $range; $StartState & "..." & $EndDate

Perform Find <-use $range in the query 

 

Edited by GisMo

1 minute ago, LaRetta said:

 

Or even:

Set Variable [ $startDate ; Get ( CurrentDate ) - 30 ] 

For some reason, I've always felt more comfortable about explicitly subtracting the day from the day element of the date constructor. 

Well, I deleted my response because I saw that John had that originally.

It would be simpler if it was just a single variable:

Set Variable [ $range ; Get ( CurrentDate ) - 30 & ".." & Get ( CurrentDate ) ]

I find removing days from a straight date the simplest rather than using Day ( $date ) - 30.

Actually, I should clarify further ... you aren't just using Day ( $date ) - 30 ... you are wrapping with the Date() function ... this all requires additional, needless evaluation and I don't find it clearer - on the contrary, it adds needless clutter.  Let's compare:

Date ( Month ( theDate ) ; Day ( theDate ) - 30 ; Year ( theDate ) )

theDate - 30

Edited by LaRetta

53 minutes ago, LaRetta said:

Date ( Month ( theDate ) ; Day ( theDate ) - 30 ; Year ( theDate ) )

theDate - 30

I am not sure which one of these requires more evaluations. But certainly the difference - if any - is negligible, and the shorter variation is much clearer.

4 hours ago, john9210 said:

finds a range of records over a 30 day period

You might find this discussion helpful for the future Date Ranges that has a link to a Custom Function and here is a file I made up. 

Magicdates.fp7.zip

  • Author

Ok, I found that using a range variable in the perfrom find step worked. Now I would like to filter a portal so that it diplays the records for dates in the last 30 days.

2 minutes ago, john9210 said:

Now I would like to filter a portal so that it diplays the records for dates in the last 30 days.

Try:

Get ( CurrentDate ) - 30 ≤ PortalTO::Datefield

This is assuming you have no future dates (or that you want to show future dates, if you have them).

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.