且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

日期设定和比较

更新时间:2023-11-29 11:05:58

试试这个......

theDate = System.DateTime.Parse(" 08-15-05");

Try this..
theDate =System.DateTime.Parse("08-15-05");


&quot ; SONU" < KR ******* @ yahoo.com>在消息中写道

news:11 ********************** @ g47g2000cwa.googlegr oups.com ...
"sonu" <kr*******@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
试试这个..
theDate = System.DateTime.Parse(" 08-15-05");
Try this..
theDate =System.DateTime.Parse("08-15-05");




这似乎有效。


但是如果我现在有一个字符串设置为日期,例如


sDate =" 09/15/05" b $ b或

s1Date =" 15-23-2005"


我如何将这些与theDate进行比较?我们在上面设置了什么?


谢谢,


Tom



That seems to work.

But if I now have a string set to a date, such as

sDate = "09/15/05"
or
s1Date = "15-23-2005"

How would I compare these to "theDate" that we set above?

Thanks,

Tom


tshad< ts**********@ftsolutions.com>写道:
tshad <ts**********@ftsolutions.com> wrote:
" sonu" &LT; KR ******* @ yahoo.com&GT;在消息中写道
新闻:11 ********************** @ g47g2000cwa.googlegr oups.com ...
"sonu" <kr*******@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
试试这个..
theDate = System.DateTime.Parse(" 08-15-05");
Try this..
theDate =System.DateTime.Parse("08-15-05");



这似乎有效。
>但是如果我现在有一个字符串设置为日期,例如

sDate =" 09/15/05"

s1Date =" 15-23- 2005

我如何将这些与theDate进行比较。我们在上面设置了什么?



That seems to work.

But if I now have a string set to a date, such as

sDate = "09/15/05"
or
s1Date = "15-23-2005"

How would I compare these to "theDate" that we set above?




以相同的方式将另一个字符串转换为DateTime,并比较

两个DateTimes(例如使用= =)。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



Convert the other string to a DateTime in the same way, and compare the
two DateTimes (eg using ==).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too