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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date error..

Status
Not open for further replies.

arravalli12

Programmer
May 3, 2005
62
0
0
US
how to check start date is greater than end date and display the error message. I am entering date in text box for start date and in anothet text box, end date.
Thanks
 
something like this...
if startdate>enddate then
'blah
else
'something
end if

may be you need to use some convert or cast functions...

-DNG
 
m using this code:
expr_dte1 = FormatDateTime(expr_dte1,0)
'response.write expr_dte1
st_dte1 = FormatDateTime(st_dte1,0)
'response.write st_dte1
if expr_dte1 < st_dte1 then
MM_abortEdit = true
emsg(e) = "start date cannot be greater than expiration date"
e = e + 1
end if %>

I get this message if I put Start date as 10/16/2005 and end date as 10/10/2005.
But if I enter st date :8/16/2005 and end date 10/10/2005. I still get the message becos there is 8 instead of 08.
How to solve this.
thanks
 
Do not format the dates as strings! If you compare them as DATES it should work just fine.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Thanks for all the help.
Finally this code worked:

if (DateDiff("d",st_dte,expr_dte)< 1) then
MM_abortEdit = true
emsg(e) = "start date cannot be greater than expiration date"
e = e + 1
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top