Announcement

Collapse
No announcement yet.

Easy way to do a DATE comparison?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scott Wolfington
    replied
    Thanks everyone for your prompt responses. I definitely have some stuff
    to try out now. Right off the bat, I like Eric's approach the best.
    It seems the quickest, although I haven't spent much time poking holes
    in this approach. Doesn't seem like there are any though.

    Thanks for the email Scott T.

    Regards,
    Scott


    ------------------
    Scott Wolfington
    http://www.boogietools.com


    [This message has been edited by Scott Wolfington (edited March 05, 2003).]

    Leave a comment:


  • Fred Oxenby
    replied
    Do yourself a favour....
    Create your date-routine around 'VARIANT TIME' (same as VB-date/time)
    and you will be able to 'do math' on them.
    Add a day,second or year...


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Eric Pearson
    replied
    Scott W. --

    All of those suggestions will work, or, if you want to keep it simple, you could just
    write a function that converts the strings to a format that can be compared directly.

    01/01/2001 --> 20010101
    02/14/2001 --> 20010214

    If you place the elements of the date in "descending" order a normal string comparison
    can be performed.

    This logic can be extended to compare date/times too, using YYYMMDDHHMMSS. Be careful
    if you use VAL to convert a date/time in that format to a numeric value, because it
    will overflow a LONG in the year 2147. Use a DWORD instead. But there's really no
    reason to use VAL when the strings can be compared directly, unless using VAL and
    a numeric comparison is faster than a string comparison. (I haven't checked.)

    -- Eric
    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited January 18, 2001).]

    Leave a comment:


  • Scott Turchin
    replied
    I emailed you my checkreg.bas file, it has everything you will need.




    Scott


    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Egbert Zijlema
    replied
    Scott,

    Use a Julian function. See the download section of my website.


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Leave a comment:


  • Scott Wolfington
    started a topic Easy way to do a DATE comparison?

    Easy way to do a DATE comparison?

    Hey all,

    Is there an easy way to do a date comparison if the dates are in
    string format? (ie. Is "01/01/2001" less than "02/14/2001")

    I'm afraid the long answer is to parse out each date, add the date parts
    to a SYSTEMTIME struct, convert the SYSTEMTIME struct to a FILETIME
    struct, and then use the CompareFileTime Windows API function to
    get my answer.

    Any ideas would be much appreciated. Thanks!

    Scott



    ------------------
    Scott Wolfington
    http://www.boogietools.com



    [This message has been edited by Scott Wolfington (edited March 05, 2003).]
Working...
X