开发者

asp date query formatting

i want to make an asp query so that an event is shown when it's date is greater or equal.

here's the code so far, but it doesn't work.

<%
    strDateNow = date
    strDateEvent = "30.05开发者_运维百科.2011"
%>

<% if strDateEvent >= strDateNow then %>
HELLO
<% end if %>

thanks for any help, alex


I assume this is VBScript + Classic ASP rather than .net?

strDateEvent is a string so the >= is not comparing dates.
To compare against strDateNow which is a date despite its name, you need to convert strDateEvent to a date in order to compare:

If CDate(strDateEvent) >= strDateNow Then

If this fails with a type error then the format "30.05.2011" cannot be converted so use another; "10/04/2011" (ensuring dmy order is appropriate for your locale)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜