April 29, 200421 yr I have put the following into a calculation: Year ( Get ( CurrentDate ) ) & Case ( Length ( Month ( Get ( CurrentDate ) ) = 1 ) ; "0") & Month ( Get ( CurrentDate ) ) & Case ( Length ( Day ( Get ( CurrentDate ) ) = 1 ) ; "0") & Day ( Get ( CurrentDate ) ) Since today's date is 4/29/04, I'd expect the result to be 20040429. FileMaker returns: 200404029. I have checked that the result of "Length ( Day ( Get ( CurrentDate ) )" is 2, NOT 1. What am I doing wrong? I am running FileMaker 7.0v1a on a dual gigahertz Macintosh G4 running OS 10.3.3. Thank you for your help.
April 29, 200421 yr That does seem odd. I'd make it easier, though, and just remove the Cases altogether. Year ( Get ( CurrentDate ) ) & Right( "00" & Month ( Get ( CurrentDate ) ); 2 ) & Right( "00" & Day ( Get ( CurrentDate ) ); 2 )
April 29, 200421 yr Though Queue has the best solution, i was intrigued... the problem lies, as you may imagine, in the element: Case ( Length ( Day ( Get ( CurrentDate ) ) = 1 ) ; "0") Follow the substitutions, watching the parentheses carefully: Case ( Length ( Day ( Get ( CurrentDate ) ) = 1 ) ; "0") Case ( Length ( Day ( <4/29/2004> ) = 1 ) ; "0") Case ( Length ( 29 = 1 ) ; "0") Case ( Length ( 0 ) ; "0") /* 29=1 is a false statement and therefore equal to FALSE, that is, the number 0 */ Case ( 1 ; "0") /* The length of the string '0' is 1 */ 0 /* 1 is a boolean TRUE, thus the case statement returns a positive and gives you your (undesired) result of 0*/ A better calculation would be: Case ( ( Length ( Day ( Get ( CurrentDate ) ) ) = 1 ) ; "0") Jerry
April 29, 200421 yr Good call. You can remove the extra parens, too. Case ( Length ( Day ( Get ( CurrentDate ) ) ) = 1 ; "0") We only needed to move the parens following the '1' before the '='.
Create an account or sign in to comment