carguy195792 Posted August 1, 2011 Posted August 1, 2011 I am running a simple Show Dialog to troubleshoot one of my scripts... If I run this calculation: "Case ("10/10/2011" ≤ Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate));"True"; )" I get "True" If I run this calculation: "Case ("9/2/2011" ≤ Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate));"True"; )" I get "" How does that make sense? I even ran: Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate)) And got 9/10/2011 So I know that at least FM is seeing the date it should.... What am I missing here?!
comment Posted August 1, 2011 Posted August 1, 2011 So I know that at least FM is seeing the date it should.... No, it's not seeing a date at all. "9/2/2011" is a text string and the comparison: "10/10/2011" ≤ "9/2/2011" returns True because in alphabetical order 1 comes before 9. Use the Date() function to calculate a date from individual components.
IdealData Posted August 1, 2011 Posted August 1, 2011 "Case ("10/10/2011" ≤ Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate));"True"; )" Sorry, but that won't work... You are trying to compare between a string item ("10/10/2011" - it's a string because it is in between quotes) and a date item - the data types cannot be used for comparison. First you must convert the string to a date type. Try GetAsDate("10/10/2011') Problem "cracked"??
carguy195792 Posted August 1, 2011 Author Posted August 1, 2011 Even with: Case (GetAsDate(10/10/2011) ≤ Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate));"True"; ) Still showing True... I am only doing this test because the following seems to be acting reversed: If[RecurringTransactions::RTNextDate ≤ Month(Get(CurrentDate))+1&"/"&10&"/"&Year(Get(CurrentDate))] When RTNextDate = 9/2/2011 the Script doesn't fire, when it = 10/10/2011, it fires P.s. - RTNextDate is a date field with a pop up Calendar, so I know it's a valid date...
comment Posted August 1, 2011 Posted August 1, 2011 You are trying to compare between a string item ("10/10/2011" - it's a string because it is in between quotes) and a date item The right side of the equation is also a text string. --- I recommend using the Date() function over GetAsDate() because it doesn't depend on the date format in use.
carguy195792 Posted August 1, 2011 Author Posted August 1, 2011 Yeah I thought about the right side after I had posted that reply... And the Date function did the trick! Just for posterity's sake, the working Calculation was: If[RecurringTransactions::RTNextDate ≤ Date(Month(Get(CurrentDate))+1;10;Year(Get(CurrentDate)))] Thank you for all your help!
Recommended Posts
This topic is 5204 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