Cat8 Posted October 21, 2004 Posted October 21, 2004 I have the following scrip that does not work... Set Field [Job System::gdate; Middle (Job System::date ; 4; 2)] If [Left (Job System::gdate; 2) = "1/" or "2/" or "3/" or "4/" or "5/" or "6/" or "7/" or "8/" or "9/"] Set Field [Job System::gdate; Middle (Job System::date ; 3; 2)] Else Exit Script End If I think there is something wrong with the If statement, because it performs: Set Field [Job System::gdate; Middle (Job System::date ; 3; 2)] no matter what it finds. Can anyone point out where I am going wrong?
transpower Posted October 21, 2004 Posted October 21, 2004 What format are you using for date and gdate?
Cat8 Posted October 21, 2004 Author Posted October 21, 2004 date is a date field, and gdate is a text field
Cat8 Posted October 21, 2004 Author Posted October 21, 2004 I tried simplifying the scrip to... Set Field [Job System::gdate; Middle (Job System::date ; 4; 2)] If [Job System::gdate = "1/" or "2/" or "3/" or "4/" or "5/" or "6/" or "7/" or "8/" or "9/"] Set Field [Job System::gdate; Middle (Job System::date ; 3; 2)] End If But it still doesn't work, its like its just ignoring the If statement and resetting the field no matter what!
-Queue- Posted October 21, 2004 Posted October 21, 2004 Why not use Set Field [Job System::gdate; Day(Job System::date)]? You'll get the same result in one step.
Cat8 Posted October 21, 2004 Author Posted October 21, 2004 Because I want the month not the day. I'm from New Zealand where the date is formatted dd/mm/yy.
-Queue- Posted October 21, 2004 Posted October 21, 2004 Then use Month(Job System::date). Date functions don't care about your system settings. They'll still return the right result.
Cat8 Posted October 21, 2004 Author Posted October 21, 2004 No wait, I figured it out... the date fields are formatted mm/dd/yy. Once I changed them to our format, it worked! Thanks
-Queue- Posted October 21, 2004 Posted October 21, 2004 The format shouldn't matter, because dates are internally stored as numbers. So Month(datefield) will work for any legal format or system setting since it doesn't pay attention to them.
transpower Posted October 21, 2004 Posted October 21, 2004 But Cat8 is using string manipulation commands, like Left and Middle, and so I think it would matter. That's why I asked for the format of date and gdate.
-Queue- Posted October 22, 2004 Posted October 22, 2004 I was referring to format, not field type. And yes, Cat was using string commands that aren't necessary when a simple Month( ) function will suffice.
transpower Posted October 23, 2004 Posted October 23, 2004 Right. Why use string manipulation when the month function will work regardless of field format!
Recommended Posts
This topic is 7599 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