如何在asp.net中对两个日期进行对位 [英] how to compair two date in asp.net

查看:75
本文介绍了如何在asp.net中对两个日期进行对位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中比较两个日期
我想用作2011年10月5日和2011年10月6日
我想在if condition.if中使用它,如果相同,则做一些事情,不相同,然后去其他部分

how to compare two date in asp.net
i want to use as 05 oct 2011 and 06 oct 2011
i want to use this in if condition.if same then do some thing and not same then do go else part
and
how can encript these date.

推荐答案

一切都太简单了.对于类型System.DataTime,您可以使用比较运算符``=='',``!='',``<'',``>'',``> ='','' < =''.您也可以使用减法(''-''),如果类型为System.TimeSpan,则为您提供值.

—SA
Everything is way too simple. For the type System.DataTime, you can use comparison operators ''=='', ''!='', ''<'', ''>'', ''>='', ''<=''. You can also use subtraction (''-'') which gives you the value if the type System.TimeSpan.

—SA


使用
convert(varchar(10),datetimepicker.text,105)
它将日期选择为2011年8月5日
use
convert(varchar(10),datetimepicker.text,105)
it select the date as 5-oct-2011


,其中dtStartdate,dtEnddate是日期时间选择器控件的ID.

here dtStartdate,dtEnddate are the id''s of datetime picker controls

dtstrt = Convert.ToDateTime(dtStartdate.Value.ToString("MM/dd/yyyy 00:00:00"));
               dtend = Convert.ToDateTime(dtEnddate.Value.ToString());
               if (DateTime.Compare(dtstrt, dtend) == 0)
               {
               //both dates same
                   
               }
               else 
               {
               //both dates are not equal
               }




如果您遇到任何与我亲密的问题,请尝试此操作




try this if you face any problem intimate me i will try in another way


这篇关于如何在asp.net中对两个日期进行对位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆