如何在vb.net中检查PM时间是否大于AM Time [英] how to check that PM time is greater than AM Time in vb.net

查看:170
本文介绍了如何在vb.net中检查PM时间是否大于AM Time的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查PM时间是否大于上午时间



例如



A>上午11:30

B> 05:00 PM



i需要下午5点大于11:30 Am因为新的更新时间是下午5点



请帮助我。

How to Check that PM Time is greater than Am Time

For Example

A> 11:30 AM
B> 05:00 PM

i need that 5 PM is Greater than 11:30 Am because new updated time is 5 PM

Please Help Me.

推荐答案

重点是什么? PM总是比AM大!没有日期部分,这种检查没有意义。更多。 AM / PM只是一种表示格式,时间(或日期时间)实际上是以二进制形式存储的(自01/01/1900以来的毫秒数),使用VB比较两个DateTime变量将为您提供准确的答案,而无需考虑如果我们在中午之前或之后...
What the point? PM is ALWAYS greater than AM!!! This kind of check has no meaning without the date part. More. The AM/PM is only a presentation format the time (or date-time) is really stored in binary (like milliseconds since the 01/01/1900), comparing two DateTime variable using VB will give you the exact answer without thinking even about if we are before or after midday...


这可能对你有帮助



http://stackoverflow.com/questions/16639675/vb-net-get-total-time-between -two-time-span [ ^ ]
this might help you

http://stackoverflow.com/questions/16639675/vb-net-get-total-time-between-two-time-spans[^]


你可以查看这段代码,它可能对你有所帮助......





you can check it out this code, it might help you...


Dim stringAM As String = "11:30 AM"
       Dim stringPM As String = "05:00 PM"

       Dim dtAM As DateTime = DateTime.Parse(stringAM)
       Dim dtPM As DateTime = DateTime.Parse(stringPM)

       If dtPM > dtAM Then
           Console.WriteLine("PM is Greter Than AM")
       Else
           Console.WriteLine("PM is Less Than AM")
       End If

       'but if you have time along with date then you can try something like this..

       Dim stringDTAM As String = "19-March-2014 11:30 AM"
       Dim stringDTPM As String = "18-March-2014 05:00 PM"

       dtAM = DateTime.Parse(stringDTAM)
       dtPM = DateTime.Parse(stringDTPM)

       If dtPM > dtAM Then
           Console.WriteLine("PM is Greter Than AM")
       Else
           Console.WriteLine("PM is Less Than AM")
       End If





注意:如果您要检查AM和PM的当天时间,那么PM总是更大比AM,但如果你试图用不同的日期检查那么你可能会得到AM大于PM,如上例所示,在第二部分中,我提到PM日期小于AM日期,在这种情况下它将返回AM大于PM



NOTE: if you are trying to check same day time for AM and PM then PM is always greater than AM, but if you are trying to check that with different dates then you might get AM is greater than PM, as shown in above example, in the second part, i have mention PM date is less then AM date, in that case it will return AM is greater then PM


这篇关于如何在vb.net中检查PM时间是否大于AM Time的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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