Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff syntax error- help me please

Status
Not open for further replies.

Bastien

Programmer
May 29, 2000
1,683
CA
Hi Guys,

I have the following code but can't seem to get the DateDiff to work. Can anyone see what I' ve got wrong.
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...

strEndDD = Request.Form ("EndDD") 'get the end date
strEndMM = Request.Form ("EndMM")
strEndYY = Request.Form ("EndYY")

strStartDD = Request.Form ("StartDD") 'get the start date
strStartMM = Request.Form ("StartMM")
strStartYY = Request.Form ("StartYY")

strEnd = strEndYY & strEndMM & strEndDD
strStart = strStartYY & strStartMM & strStartDD

'some validation and checking for the 1st time opening of the form
if not IsDate(strEnd) and not IsDate (strStart) then 'if empty then create the form to request the dates
strNote=0
call CreateForm
elseif DateDiff(d, strStart,strEnd) < 0 then 'if end date not valid
strNote = 1
call CreateForm
...


TIA

Bastien
 
You are not passing DATE variants, you are passing strings. You also used DateDiff(d instead of DateDiff(&quot;d&quot;.
Code:
Dim dteStart
Dim blnError
On error resume next
    dteStart = DateSerial(Cint(strStartYY),Cint(strStartMM),Cint(strStartDD))
    if Err.Number <> 0 then blnerror = True
On Error goto 0
If blnError then
....bad date
End if
if DateDiff(&quot;d&quot;, strStart,strEnd)
 
Hi john

thanks for your tip...but when I try it I get 11/30/99 as a date when the fields are left blank. ie when the form opens up for the first time, there are no values in the fields but I get 11/30/99....

any ideas
Bastien
 
I don't have the example in front of me but there is a ContentLength variable that if 0 indicates the first time or at least a blank form. You could also use a hidden input field that will not have a value on first entry but you set to &quot;Y&quot; on output.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top