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!

Advanced FormatDateTime Issue - Help needed 1

Status
Not open for further replies.

justinpl

Programmer
Nov 20, 2003
19
0
0
US
FormatDateTime("11/05/2003", 2) will equal 11/5/2003

11/05/2003 and 11/5/2003 are not read the same way in .asp

The problem:

<% If FormatDateTime(&quot;11/05/2003&quot;, 2) > FormatDateTime(&quot;11/12/2003&quot;, 2) Then %>
YES
<% Else %>
NO
<% End If %>

This code states that 11/5/2003 is greater than 11/12/2003, which is not correct.

I tried all the examples in the ASP FAQ 3195 and none worked. DAY(&quot;11/05/2003&quot;) still outputs 11/5/2003. I need a way to get the above if - then - else statement to read NO. Any suggestions?
 
<%@language=vbscript%>

<%
dim dt

dt = FormatDateTime(&quot;11/05/2003&quot;, 2)

dd = day(dt)
if len(dd) = 1 then
dd = &quot;0&quot; & dd
end if

mm = month(dt)
yyyy = year(dt)

Response.Write (&quot;<html>&quot;)
Response.Write (&quot;<body>&quot;)
Response.Write dt
Response.Write (&quot;<br>&quot;)
Response.Write (mm & &quot;/&quot; & dd & &quot;/&quot; & yyyy)
Response.Write (&quot;</body>&quot;)
Response.Write (&quot;</html>&quot;)
%>

Regards,

Patrick
 
Try this

If cDate(&quot;11/05/2003&quot;, 2) > cDate(&quot;11/12/2003&quot;, 2) Then
response.write 'yes'
else
response.write 'no'
end if

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
DOH - typo...

If cDate(&quot;11/05/2003&quot;) > cDate(&quot;11/12/2003&quot;) Then
response.write 'greater than'
else
response.write 'less than or equal'
end if

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Thank you guys a ton!!! That worked great...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top