john9210 Posted November 19, 2015 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?
GisMo Posted November 19, 2015 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
GisMo Posted November 19, 2015 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.
LaRetta Posted November 19, 2015 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.
LaRetta Posted November 19, 2015 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
comment Posted November 19, 2015 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
Lee Smith Posted November 19, 2015 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
john9210 Posted November 19, 2015 Author 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.
comment Posted November 19, 2015 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).
Recommended Posts
This topic is 3291 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