home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / datecomp / datecomp.bas next >
BASIC Source File  |  1994-07-11  |  1KB  |  34 lines

  1.  
  2. Function DateComp& (Date1 As Variant, Date2 As Variant)
  3.  
  4.   Dim Tmp1$, Tmp2$
  5.  
  6.   ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  7.   ''                                                  ''
  8.   ''  DateComp Function:  Compares two dates and      ''
  9.   ''    returns <0 if Date1 < Date2                   ''
  10.   ''             0 if Date1 = Date2 and               ''
  11.   ''            >0 if Date1 > Date2                   ''
  12.   ''                                                  ''
  13.   ''  Date values should be passed in MM-DD-YYYY fmt  ''
  14.   ''  Ex: 03-24-1994.  This format can be obtained    ''
  15.   ''  using the Format$() function. See VB Help for   ''
  16.   ''  more info on that if you're unsure.             ''
  17.   ''                                                  ''
  18.   ''  After this function exits, you can convert the  ''
  19.   ''  values back to whatever date format you need.   ''
  20.   ''                                                  ''
  21.   ''  See the enclosed example in the sub main.       ''
  22.   ''                                                  ''
  23.   ''  By Richard Wray, CIS 74053,3710                 ''
  24.   ''                                                  ''
  25.   ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  26.  
  27.   ' First check year value.  If years are different,
  28.   ' we know which one is greater, so exit.
  29.  
  30.   DateComp& = DateValue(Date1) - DateValue(Date2)
  31.  
  32. End Function
  33.  
  34.