john9210 Posted November 19, 2015 Share Posted November 19, 2015 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? Link to comment Share on other sites More sharing options...
GisMo Posted November 19, 2015 Share Posted November 19, 2015 (edited) 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 November 19, 2015 by GisMo Link to comment Share on other sites More sharing options...
GisMo Posted November 19, 2015 Share Posted November 19, 2015 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. Link to comment Share on other sites More sharing options...
LaRetta Posted November 19, 2015 Share Posted November 19, 2015 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. Link to comment Share on other sites More sharing options...
LaRetta Posted November 19, 2015 Share Posted November 19, 2015 (edited) 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 November 19, 2015 by LaRetta Link to comment Share on other sites More sharing options...
comment Posted November 19, 2015 Share Posted November 19, 2015 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. 1 Link to comment Share on other sites More sharing options...
Lee Smith Posted November 19, 2015 Share Posted November 19, 2015 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 Link to comment Share on other sites More sharing options...
john9210 Posted November 19, 2015 Author Share Posted November 19, 2015 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. Link to comment Share on other sites More sharing options...
comment Posted November 19, 2015 Share Posted November 19, 2015 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). Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 3208 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