Date conversion

Results 1 to 3 of 3

Thread: Date conversion

  1. #1
    Anne Guest

    Default Date conversion

    I have a form that users select the date from 3 drop downs:<BR>Month, Day and Year. I need to take the 3 form fields and convert them from a string into a date format such as 10/12/2000 so that I can validate that the Date(Now) is at least 3 days from the date they entered on the form. If there is less than 3 days between the 2 dates, the form will not submit. Has anyone seen any helpful articles that deal with this? I have searched various sites but to no avail.<BR>Thanks!

  2. #2
    Dan White Guest

    Default RE: Date conversion

    You need to use the CDate function. First concatenate your three strings, remembering to include "/" between each string, and putting the values in in Month, Day, Year order. Then CDate(string). Finally do a DateDiff to work out the number of days between the resulting date and the date you are referring to. Then use a condition to determine whether or not the difference in days is greater than 3.<BR><BR>&#060;%<BR>strDay = "21"<BR>strMonth="10"<BR>strYear="2000"<BR><BR>str Date = strMonth & "/" & strDay & "/" & strYear<BR><BR>Response.Write strDate & "&#060;p&#062;"<BR><BR>strDate = CDate(strDate)<BR><BR>Response.Write strDate & "&#060;p&#062;"<BR><BR>strElapse = DateDiff("d",Now,strDate)<BR><BR>If strElapse &#062; 3 Then<BR> Response.Write "More than 3 days left"<BR>Else<BR> Response.Write "Soon and very soon..."<BR>End If<BR>%&#062;<BR><BR>Good luck,<BR><BR>Dan<BR>Serving Jesus

  3. #3
    Anne Guest

    Default Thanks very much for your help Dan!


Posting Permissions

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