DateDiff syntax problem

Results 1 to 3 of 3

Thread: DateDiff syntax problem

  1. #1
    Join Date
    Dec 1969

    Default DateDiff syntax problem

    May 8, 2001 <BR>Hi Guys,<BR><BR>I have the following code but can&#039;t seem to get the DateDiff to work. Can anyone see what I&#039; ve got wrong.<BR>I request the dates and combine them into one string and then need to error check to see if the Enddate is earlier than the StartDate...<BR><BR>strEndDD = Request.Form ("EndDD") &#039;get the end date<BR>strEndMM = Request.Form ("EndMM")<BR>strEndYY = Request.Form ("EndYY")<BR><BR>strStartDD = Request.Form ("StartDD") &#039;get the start date<BR>strStartMM = Request.Form ("StartMM")<BR>strStartYY = Request.Form ("StartYY")<BR><BR>strEnd = strEndYY & strEndMM & strEndDD<BR>strStart = strStartYY & strStartMM & strStartDD<BR><BR>&#039;some validation and checking for the 1st time opening of the form<BR>if not IsDate(strEnd) and not IsDate (strStart) then &#039;if empty then create the form to request the dates<BR> strNote=0<BR> call CreateForm<BR>elseif DateDiff(d, strStart,strEnd) &#060; 0 then &#039;if end date not valid<BR> strNote = 1<BR> call CreateForm <BR>...<BR><BR><BR>TIA<BR><BR>Bastien <BR>

  2. #2
    Reggie Guest

    Default 2 problems

    Response.write the two dates (strEnd and strDate) so you can see what they look like. You need them in the format mm/dd/yyyy with the slashes in there (maybe you can get away with just yy). After that you will probably need to use cDate() on both of them to convert them to the Date data type.<BR><BR>strEnd = cDate(strEndDD &"/"& strEndMM &"/"& strEndYY)

  3. #3
    Join Date
    Dec 1969

    Default RE: DateDiff syntax problem

    need to CDate enddate & startdate before you use them in datediff.

Posting Permissions

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