Comparing date values

Results 1 to 3 of 3

Thread: Comparing date values

  1. #1
    Join Date
    Dec 1969

    Default Comparing date values

    Hi,<BR>This is the VBScript question:<BR>I need to validate(client side using VBScript) values of 2 dates on the form before submiting it.I used IsDate function to check if values are dates (work OK)but I have a problem how to check that dateEnd is later then dateStart.I tried:<BR>if document.entry.dateStart.value &#060; document.entry.dateEnd.value then<BR>MsgBox"....<BR>but it is not working.<BR>How should I check if dateEnd is later then dateEnd?<BR>Any help appreciated,<BR>Lyn

  2. #2
    Join Date
    Dec 1969

    Default RE: Comparing date values

    1) you know client side VB will only work on IE?<BR><BR>2) try using cdate(document.entry.blahblah) &#060; cdate(document.entry.blah)<BR><BR>You *can* use &#060;&#062; to evaulate dates in VBS, so the only thing I can think of is that it isn&#039;t a VB Date... which makes sense since it&#039;s coming from a text box VB is treating it as a string.

  3. #3
    Join Date
    Dec 1969

    Default VBScript, not VB...

    (just had to twit ShaneH for that...&#060;snicker/&#062;)<BR><BR>Yes, Shane is 100% right.<BR><BR>The .value property of *ANY* form field on the client is *ALWAYS* a text string.<BR><BR>You tested the values to make sure they were dates, using isDate( ), but all that does is *internally* convert them from strings to dates.<BR><BR>To *use* them as date values you have to use CDate (which means "Convert to DATE").<BR><BR>Fair warning for the future: For numeric values, you would similarly want to use isNumeric() to test and CDbl() to convert from string to real number.<BR><BR>

Posting Permissions

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