November 19, 201510 yr 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?
November 19, 201510 yr 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, 201510 yr by GisMo
November 19, 201510 yr 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.
November 19, 201510 yr 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.
November 19, 201510 yr 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, 201510 yr by LaRetta
November 19, 201510 yr 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.
November 19, 201510 yr 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
November 19, 201510 yr 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.
November 19, 201510 yr 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