Newbies Craig Wells Posted April 2, 2008 Newbies Posted April 2, 2008 So I have a timecard DB that should restrict the days that they view to the pay period that they are in. I created a case script step to do this, but it sometimes works and sometimes it doesn't and I can't think of a reason why. Below is the text of the script I'm using to restrict the dates. The output I'm getting today for example is this: 4/11/08...4/02/08 Obviously this isn't going to work as a legitimate find. Is there some completely obvious thing that I'm missing that is causing the script to sometimes work and then sometimes produce the preceding? Craig Wells Set Field [ timecard::holding; "" ] Set Field [ timecard::holding Copy; "" ] Insert Calculated Result [ timecard::holding; Case ( Get ( CurrentDate ) ≤ "1/10/2008" ; "12/26/2007"; Get ( CurrentDate ) ≤ "1/28/2008" ; "1/11/2008" ; Get ( CurrentDate ) ≤ "2/12/2008" ; "1/29/2008" ; Get ( CurrentDate ) ≤ "2/26/2008" ; "2/13/2008" ; Get ( CurrentDate ) ≤ "3/11/2008" ; "2/27/2008" ; Get ( CurrentDate ) ≤ "3/26/2008" ; "3/12/2008" ; Get ( CurrentDate ) ≤ "4/10/2008" ; "3/26/2008" ; Get ( CurrentDate ) ≤ "4/25/2008" ; "4/11/2008" ; Get ( CurrentDate ) ≤ "5/12/2008" ; "4/26/2008" ; Get ( CurrentDate ) ≤ "5/27/2008" ; "5/13/2008" ; Get ( CurrentDate ) ≤ "6/10/2008" ; "5/28/2008" ; Get ( CurrentDate ) ≤ "6/25/2008" ; "6/11/2008" ; Get ( CurrentDate ) ≤ "7/10/2008" ; "6/26/2008" ; Get ( CurrentDate ) ≤ "7/28/2008" ; "7/11/2008" ; Get ( CurrentDate ) ≤ "8/12/2008" ; "7/29/2008" ; Get ( CurrentDate ) ≤ "8/26/2008" ; "8/13/2008" ; Get ( CurrentDate ) ≤ "9/10/2008" ; "8/27/2008" ; Get ( CurrentDate ) ≤ "9/25/2008" ; "9/11/2008" ; Get ( CurrentDate ) ≤ "10/10/2008" ; "9/26/2008" ; Get ( CurrentDate ) ≤ "10/28/2008" ; "10/11/2008" ; Get ( CurrentDate ) ≤ "11/11/2008" ; "10/29/2008" ; Get ( CurrentDate ) ≤ "11/21/2008" ; "11/12/2008" ; Get ( CurrentDate ) ≤ "12/10/2008" ; "11/22/2008" ; Get ( CurrentDate ) ≤ "12/26/2008" ; "12/11/2008" ; "12/27/2008") ] [ Select ] Insert Current Date [ timecard::holding Copy ] [ Select ] Enter Find Mode [ ] Insert Calculated Result [ timecard::employeeID; Get ( AccountName ) ] [ Select ] Insert Calculated Result [ timecard::Date; timecard::holding & "..." & timecard::holding Copy ] [ Select ] Perform Find [ ]
bcooney Posted April 2, 2008 Posted April 2, 2008 I don't have time to test, but I've rarely used Insert Calc Result. It requires the field to be on the layout. Why did you use that rather than a Set Field? Also, before entering Find mode, why not store the two dates in variables (or globally stored fields)? That is the main problem that I see. There's got a be a better calc for determining the date range. Anyone?
comment Posted April 2, 2008 Posted April 2, 2008 I think your immediate problem is this: "4/10/2008" is a text string, not a date. In order to make a meaningful comparison, you need to write: Get ( CurrentDate ) ≤ GetAsDate ("4/10/2008" ) or preferably: Get ( CurrentDate ) ≤ Date ( 4 ; 10 ; 2008 ) However, this doesn't seem like a good method overall. What will you do in 2009 - rewrite your script? If there is logic behind this mountain of conditions, why not let the script know what it is, so it can produce the correct result on any date, past or future?
Newbies Craig Wells Posted April 2, 2008 Author Newbies Posted April 2, 2008 Using GetAsDate resolved the issue that I was having. As far as the suggestions regarding the overall structure of the script, I agree that yes it would be better to let the script determine the date based on method used to chose the dates in the first place, but I am unaware of those methods at this point and had a list of the dates and getting it working was more important. I will rewrite it later to do the things you suggested Having the insertion fields on the layout is of no consequence since I restrict their use and make them invisible to the user so they don't even know it exists. If there is a reason that this is an issue I would love some suggestions in this area. Thanks Again Craig Wells
comment Posted April 2, 2008 Posted April 2, 2008 It's better to use Set Field[] since it works always, and will continue to work if you remove the fields from the layout. Another point: since it seems that the current date is the only input here, you don't need all this shuffling around. You can get directly to the point: Enter Find Mode [ ] Set Field [ timecard::employeeID; Get ( AccountName ) ] Set Field [ timecard::Date ; Case ( < your mile-long Case statement here > ) & "..." & GetCurrentDate ] Perform Find [ ]
Recommended Posts
This topic is 6080 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