Alpha Video Training
Results 1 to 6 of 6

Thread: Can't Decrease Date?

  1. #1
    Jim Faliveno
    Guest

    Default 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??

  2. #2
    "Certified" Alphaholic
    Real Name
    Ohlen Cartmell
    Join Date
    Apr 2000
    Posts
    1,599

    Default 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.

  3. #3
    Jim Faliveno
    Guest

    Default 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?

  4. #4
    "Certified" Alphaholic
    Real Name
    Ohlen Cartmell
    Join Date
    Apr 2000
    Posts
    1,599

    Default 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.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default 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")

  6. #6
    Jim Faliveno
    Guest

    Default 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.

Similar Threads

  1. Date format when typing in the date?
    By Wanda Tucker in forum Web Application Server v6
    Replies: 1
    Last Post: 10-02-2005, 02:08 PM
  2. Start date & Week ending date..
    By rae4sp in forum Alpha Five Version 6
    Replies: 2
    Last Post: 09-22-2005, 11:29 AM
  3. Roll Box to increase/decrease a numeric field
    By Mantford in forum Alpha Five Version 5
    Replies: 5
    Last Post: 04-30-2003, 08:52 PM
  4. Date Prompt Using 2 Date Fields
    By forskare in forum Alpha Five Version 5
    Replies: 5
    Last Post: 10-08-2002, 03:22 AM
  5. How do you compare a date to a null date?
    By Ilesh Mistry in forum Alpha Five Version 4
    Replies: 5
    Last Post: 10-29-2001, 03:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •