-
Can't Decrease Date?
I have a form on which there are two fields which display the content of variables.
1 Variable is named StartDate and The other is EndDate. they are both global.
In the form are 2 buttons. 1 to increase the EndDate by one month with each click and the other to decrease the date 1 month per click.
The increase date button works using =addmonths(Var->EndDate,1) followed by refresh fields.
Can someone tell me the function to use to decrease the date. I tried =addmonths(Var->EndDate,-1) (note the -1) but it throws an error. There doesn't seem to be a decmonths or submonths function??
-
RE: Can't Decrease Date?
This works in the interactive window:
dim enddate as d
enddate=date()
?enddate
= {01/13/2004}
?addmonths(enddate,1)
= {02/13/2004}
?addmonths(enddate,-1)
= {12/13/2003}
Try dropping the var->enddate in favor of enddate.
-
RE: Can't Decrease Date?
Ohlen:
I appreciate your response. What is so exasperating about this program is that =addmonths(EndDate,1) but =addmonths(EndDate,-1) does not!
I tried your suggestion and the error message says:
Script: OnPush Line 9
EndDate=convert_type(A5_eval_expression("-addmonths(EndDate,-1)"),"C")
variable type mismatch
The error is exactly the same with or without the var->
???
any other ideas?
-
RE: Can't Decrease Date?
I think it's because you are assigning a character value determined by the A5_eval_expression() function to a date variable.
-
RE: Can't Decrease Date?
I'm not clear how you are getting the script attached to the button. Start over, create a new button, use xbasic editor, put the code
enddate = addmonths(enddate,-1)
in the box, finish the button, save the form, and it should work. Have no idea how this is getting translated into
convert_type(A5_eval_expression("-addmonths(EndDate,-1)"),"C")
-
RE: Can't Decrease Date?
Stan:
Thank you. That worked. Just FYI, I used the script editor to create the function script and A5 created that function with the "C" in it I believe the script editor created the problem.
I guess I just learned "another" work around.
Thank you very much for the coaching.