Alpha Video Training
Results 1 to 11 of 11

Thread: Between and CTOD() not working for me

  1. #1
    Member MikeData's Avatar
    Real Name
    Mike Data
    Join Date
    Nov 2008
    Posts
    923

    Default Between and CTOD() not working for me

    This works:
    (pR = "Open" ).and. (MGR = "king") .and. (between(opendate("03/01/2011"),ctod("03/15/2011")) ) .AND. closedate <{01/01/80 }

    I want to replace the literals with variables
    =====================
    Pick1 = “Open” -- pick2 = “King” -- gdte1 = 03/01/2011 -- gdte2 = 03/15/2011
    =======================
    pcik1 and pick 2 works ok. using GDTE1 and GDTE2, does not

    (pR = var->pick1 ).and.(MGR = var->pick1).and.(between(opendate(var->gdte1 ),ctod(var->gdte2 )) ).AND. closedate <{01/01/80 }

    What is the proper syntax?

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

    Default Re: Between and CTOD() not working for me

    What does this mean?

    03/01/2011

    Is this stored as character or date?


    Here

    between(opendate(var->gdte1 ),ctod(var->gdte2 ))

    I think you want

    between(opendate,ctod(var->gdte1 ),ctod(var->gdte2 ))

  3. #3
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,213

    Default Re: Between and CTOD() not working for me

    Code:
    (pR = var->pick1 ).and.(MGR = var->pick1).and.(between(opendate(var->gdte1 ),ctod(var->gdte2 )) ).AND. closedate <{01/01/80 }
    Mike,
    You didn't show us how you dimmed your variables.

    gdte1 = 03/01/2011 -- gdte2 = 03/15/2011. this won't fly under any circumstances. they need quotes for character or curly brackets for date.

    I couldn't find any documentation on the opendate() function.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  4. #4
    Member MikeData's Avatar
    Real Name
    Mike Data
    Join Date
    Nov 2008
    Posts
    923

    Default Re: Between and CTOD() not working for me

    let me requote
    This works:
    (pR = "Open" ).and. (MGR = "king") .and. (between(opendate,ctod("03/01/2011"),ctod("03/15/2011")) ) .AND. closedate <{01/01/80 }

    I want to replace the literals with variables
    =====================
    Pick1 = “Open” -- pick2 = “King” -- gdte1 = 03/01/2011 -- gdte2 = 03/15/2011
    =======================
    pick1 and pick 2 works ok. using GDTE1 and GDTE2, does not

    (pR = var->pick1 ).and.(MGR = var->pick1).and.(between(opendate,ctod(var->gdte1 ),ctod(var->gdte2 )) ).AND. closedate <{01/01/80 }
    ------------

    The words in red were missing.
    pr, mgr, opendate and closedate are fields in the browse.

    I dim those gdtes globals in autoexec. They are populated later under an xdialog.
    This code is the filter to open a browse.

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,312

    Default Re: Between and CTOD() not working for me

    Hey, Mike.

    To learn how to fish study this page.

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

    Default Re: Between and CTOD() not working for me

    Maybe

    Code:
    (pR = var->pick1 ).and.(MGR = var->pick2).and.(between(opendate,ctod(var->gdte1 ),ctod(var->gdte2 )) ).AND. closedate <{01/01/80 }

  7. #7
    Member MikeData's Avatar
    Real Name
    Mike Data
    Join Date
    Nov 2008
    Posts
    923

    Default Re: Between and CTOD() not working for me

    Thanks for the responses.
    That was a great address, Tom.
    Stan I did correct the misspelled and still did not work.
    I delete the proecess and re-created.
    It worked.
    It seems that once is created via a genie and it is improperly created, requires to rewrite it. I will keep track to see if I get a similar situation.

  8. #8
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default Re: Between and CTOD() not working for me

    For anyone reading this, these variables appear to be global based on the leading "g". If not, things change dramatically....

    Any layout you are sending the string to probably won't recognize local variables. (Assuming you are using this filter for a layout other than the form you are currently viewing.)

    Whenever you send a filter or order expression to a layout, you must remember that (A) you are just sending a text STRING to the layout and (B) the layout probably can't see the local (and/or shared?) variables in your calling script. In other words, variables must either be GLOBAL or converted to the appropriate text.

    If "ctod(var->gdte1 )" doesn't work and you don't want to make the variable global, change the string to something like this:

    "ctod(\"" + var->gdte1 + "\")"

    or, since the date is a string value to start with, this is probably even easier:

    "...opendate,{" + gdte1 + "},...

    which results in: "...opendate,{04/07/2011},...

    And, you actually don't even need the "var->" in these cases since it's only being used in the local script. BUT, you DO need the "var->" when sending it as a global variable - otherwise the layout will be looking for a field by that name rather than a variable. (Confused yet?)

  9. #9
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Between and CTOD() not working for me

    Reading this thread fast..way too fast..just a quick observation:

    In your expression you have:
    between(ctod(var->gdte1 ),ctod(var->gdte2 ))
    Have you tried:
    between_date(ctod(var->gdte1 ),ctod(var->gdte2 ))

  10. #10
    Member MikeData's Avatar
    Real Name
    Mike Data
    Join Date
    Nov 2008
    Posts
    923

    Default Re: Between and CTOD() not working for me

    I did not tried:
    between(opendate,ctod(var->gdte1 ),ctod(var->gdte2 ))
    because the code:
    between_date(ctod(var->gdte1 ),ctod(var->gdte2 )) as I mentioned in post 7, did work. I think my problem was, it had to do with the genie process.

  11. #11
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Between and CTOD() not working for me

    I don't see in any post where you used between_date() instead of between()

Similar Threads

  1. CtoD() of particular Format
    By SMARTII in forum Alpha Five Version 9 - Desktop Applications
    Replies: 4
    Last Post: 08-20-2010, 02:14 PM
  2. ctod()
    By G Gabriel in forum Alpha Five Version 8
    Replies: 5
    Last Post: 04-03-2007, 09:36 PM
  3. CTOD (What am I doing wrong??)
    By Rich Hartnett in forum Alpha Five Version 7
    Replies: 14
    Last Post: 02-13-2007, 12:39 PM
  4. Xbasic - CTOD Problems with new computers
    By James Watson in forum Alpha Five Version 4
    Replies: 2
    Last Post: 03-21-2002, 04:05 AM
  5. Problem with CTOD
    By Jeff Kerman in forum Alpha Four Version 6 and Prior
    Replies: 4
    Last Post: 08-17-2000, 07:31 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
  •