date comparison

Results 1 to 5 of 5

Thread: date comparison

  1. #1
    hopie Guest

    Default date comparison

    Hi...<BR><BR>I&#039m retrieving dates from a csv file, (userswinstalldate)to compare later...<BR>&#039truedate&#039 is the date i get from the user.<BR>I want to compare the dates in the file with the date from user, and then display the reports for which userswinstalldate is greater or equal to the date from user(truedate).<BR><BR>I get the error when I use datevalue function, and if I don&#039t use, I don&#039t get the correct results...since they are comparing strings and not dates ...<BR>can anyone tell me what&#039s the error here with datevalue?<BR><BR>Do While NOT objText.AtEndOfStream<BR> strline = objText.ReadLine<BR> splitter = split(strline,";")<BR><BR> UserSwInstallDate_time = split(splitter(8)," ")<BR> UserSwInstallDate = UserSwInstallDate_time(0)<BR> <BR><BR>if (DateValue(UserSwInstallDate) &#062;= Datevalue(truedate) )<BR><BR>.......<BR><BR>dateValue(truedate) gives no error, <BR>but datevalue(userswinstalldate) gives:<BR><BR>Microsoft VBScript runtime error &#039 800a000d&#039 <BR>Type mismatch: &#039DateValue&#039 <BR><BR>is there any other way to compare dates coz I can&#039t get it with datevalue.....pls help...<BR>thanks....<BR><BR><BR>

  2. #2
    Ian Stallings Guest

    Default RE: date comparison

    You can use the DateDiff Function to compare two dates like so:<BR><BR>&#060;%<BR>&#039first i grab the day from the current date<BR>trueDate = DatePart("d",Date)<BR><BR>&#039then i add 30 days to the current date<BR>OtherDate = DateAdd("d",30,Date)<BR><BR>&#039then grab the day from this<BR>OtherDate = DatePart("d",OtherDate)<BR><BR>&#039then i can get the difference using DateDiff<BR>Response.write(DateDiff("d",OtherDate, TrueDate))<BR>%&#062;<BR><BR>I hope this helps :)<BR><BR>e

  3. #3
    Richard L. Guest

    Default RE: date comparison

    It would be helpful to see the string values you&#039re setting userswinstalldate to. Try returning VarType(userswinstalldate), if it&#039s not 7 or 8, you are passing a type DateValue can&#039t read.<BR><BR>Try forcing userswinstalldate to a string with Cstr(userswinstalldate) and then pass it to DateValue.<BR><BR>HTH,<BR>Richard

  4. #4
    hopie Guest

    Default RE: date comparison

    I checked fpr the varType and it returns me 8....<BR>but still when I use the datevalue, I get the same error...<BR><BR>temp = CStr(UserInstallDate)<BR>temp_ = dateValue(temp)<BR><BR>I get &#039Type mismatch dateValue&#039..........<BR><BR>any more hope?:) thanks


  5. #5
    hopie Guest

    Default RE: date comparison

    I realise that the date I&#039m retrieving from my file is not a valid date when I use the IsDate function...It appears to be in the format of a date like 31/8/99 but it actually is not when i test it in the script...<BR><BR>My question is now how to make it into a valid date?????????<BR>seems impossible??? is there a way?? coz I must read from the file and I do get the date...except that it doesn&#039t seem to be valid for other functions like dateValue or Datediff to be performed!<BR><BR>Help pls...thanks a lot...

Posting Permissions

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