Hi,
I need to determine the hightest date between e.g. "8/3/2004" and
"8/4/2004".
With this code, i get 'dat2' , which means that "8/4/2004" is higher than
"8/3/2004". That 's right.
But with "8/3/2004" and from "8/10/2004" (also "8/11/2004" ...) i get
'dat1'.
<%
dat1="8/3/2004"
dat2="8/10/2004"
if dat1>dat2 then
response.write("dat1")
else
response.write("dat2")
end if
%>
Why does that not produce 'dat2'?
Thanks
bjorn 9 1335
Bjorn wrote: Hi,
I need to determine the hightest date between e.g. "8/3/2004" and "8/4/2004". With this code, i get 'dat2' , which means that "8/4/2004" is higher than "8/3/2004". That 's right. But with "8/3/2004" and from "8/10/2004" (also "8/11/2004" ...) i get 'dat1'. <% dat1="8/3/2004" dat2="8/10/2004" if dat1>dat2 then response.write("dat1") else response.write("dat2") end if %>
Why does that not produce 'dat2'?
Because you are comparing strings. "8/3" is greater than "8/1" when you are
ordering them "alphabetically". You need to convert the strings to dates in
order to compare them as dates. Use the CDate() function, or better yet,
Dateserial(). If you do not have the vbscript documentation, you can
download it from here: http://tinyurl.com/7rk6
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
> dat1=CDate("8/3/2004") dat2=CDate("8/10/2004")
<%
dat1=FormatDateTime(#8/3/2004 11:59 AM#, 2)
dat2=FormatDateTime(#8/10/2004 11:59 AM#, 2)
if dat1>dat2 then
response.write("dat1")
else
response.write("dat2")
end if
%>
"Bjorn" <no****@rt.sw> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl... Hi,
I need to determine the hightest date between e.g. "8/3/2004" and "8/4/2004". With this code, i get 'dat2' , which means that "8/4/2004" is higher than "8/3/2004". That 's right. But with "8/3/2004" and from "8/10/2004" (also "8/11/2004" ...) i get 'dat1'. <% dat1="8/3/2004" dat2="8/10/2004" if dat1>dat2 then response.write("dat1") else response.write("dat2") end if %>
Why does that not produce 'dat2'? Thanks bjorn
thanks
"John" <n o b o d y@spam.com> wrote in message
news:BY***********************@phobos.telenet-ops.be... dat1=CDate("8/3/2004") dat2=CDate("8/10/2004")
The other posters seem to be pointing you in the right direction, but I
thought I'd mention that it is much better if you use a universal date
format since your '8/3/2004' could refer to 8th March or 3rd August
depending on other factors. '20040803' is [unambiguously] March 3rd.
See http://www.aspfaq.com/show.asp?id=2023
And actually, I'm willing to bet that that's exactly what's going.
You're comparing 08 MAR 2004 to 03 AUG 2004.
David H
CJM wrote: The other posters seem to be pointing you in the right direction, but I thought I'd mention that it is much better if you use a universal date format since your '8/3/2004' could refer to 8th March or 3rd August depending on other factors. '20040803' is [unambiguously] March 3rd.
See http://www.aspfaq.com/show.asp?id=2023
No, it wouldn't take one m/d/y and another m/d/y and only transpose one of
them.
The problem is that the string "8/3..." comes before the string "8/1..."
-- http://www.aspfaq.com/
(Reverse address to reply.)
"David C. Holley" <Da**********@netscape.net> wrote in message
news:OD**************@TK2MSFTNGP10.phx.gbl... And actually, I'm willing to bet that that's exactly what's going. You're comparing 08 MAR 2004 to 03 AUG 2004.
David H
CJM wrote: The other posters seem to be pointing you in the right direction, but I thought I'd mention that it is much better if you use a universal date format since your '8/3/2004' could refer to 8th March or 3rd August depending on other factors. '20040803' is [unambiguously] March 3rd.
See http://www.aspfaq.com/show.asp?id=2023
Aaron [SQL Server MVP] wrote: No, it wouldn't take one m/d/y and another m/d/y and only transpose one of them.
The problem is that the string "8/3..." comes before the string "8/1..."
Hmm - that statement sounds familiar ... ;-)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
David C. Holley wrote: And actually, I'm willing to bet that that's exactly what's going. You're comparing 08 MAR 2004 to 03 AUG 2004.
More to the point, CYMD formats can be compared as strings, so no date
conversion is required for sorting. Together with its complete lack of
ambiguity, this format is hard to beat.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Will Stuyvesant |
last post by:
Here is a question about list comprehensions . The
question is dumb because I can do without ; but I am
posing the question because I am curious.
This:
>>> data = ,,]
>>> result =
>>> for...
|
by: Christian Schmidbauer |
last post by:
Hello!
I prepare my XML document like this way:
-------------------------------------------------------
PrintWriter writer;
Document domDocument;
Element domElement;
// Root tag
|
by: Diandian Zhang |
last post by:
Does anyone have an idea, how to do it? Thanks in advance!
|
by: raj |
last post by:
I used to remember why c++ needed both ?
Could somebody help me here ?
For example
class A{
f();
};
A* aa;
|
by: |
last post by:
I used to remember why c++ needed both.
For example
class A{
f();
};
|
by: andrew007 |
last post by:
I do xml / xslt transformation using asp.net but I found
any value (w/xml format) in xml node html-encoded to < and > format if
it's > or < tag.
Since I have sub xml data in a parent xml node...
|
by: John Nagle |
last post by:
This, which is from a real web site, went into BeautifulSoup:
<param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer
fantastic rates for selected weeks or days!!&blinkt=Click...
|
by: Wojciech Gryc |
last post by:
Hi,
I recently started using Python and am extremely happy with how
productive it's made me, even as a new user. I'm hoping to continue
using the language for my research, and have come across a...
|
by: ismailc |
last post by:
Hi, I need help please.
Update system to to new version & moved on to .Net2
But now my code that worked in my .Net1 xslt does not work.
.Net1 fine:
<xsl:stylesheet...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |