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!

Easy way to compare Dates

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
Is there an easy way to compare dates. I have done it using the datediff but I was hoping for less code.

something easy like this

if Date() >= &quot;09/16/02&quot; and Date() <= &quot;09/22/02&quot; then

but this does not work.

Any ideas
AJ
I would lose my head if it wasn't attached. [roll1]
 
if Date() >= cdate(&quot;09/16/02&quot;) and Date() <= cdate(&quot;09/22/02&quot;) then
 
You can use the DateDiff function - Returns the number of intervals between two dates.
<%
option explicit
dim date1, date2, diff

date2 = &quot;01/01/2003&quot;
date1 = now()
diff = DateDiff(&quot;d&quot;, date1, date2)

Response.Write diff & &quot; days left to &quot; & date2
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top