本文介绍了如何在年,月,日两个日期之间取得差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vb.net中的年,月,日中区分两个datetimepickers。

How to get difference between two datetimepickers in Years,Months,days in vb.net.

我正在使用VB 2008。

I am using VB 2008 .

推荐答案

请在此处查看示例代码:

See the example code here:

https://msdn.microsoft.com/de-de/library/b5xbyt6f(v = vs.90).aspx

https://msdn.microsoft.com/de-de/library/b5xbyt6f(v=vs.90).aspx

或简单地减去日期(从中获取日期) datetimepickers):

or simply subtract the dates (get them from the datetimepickers):

        Dim datTim1 As Date = #1/4/2001#
        Dim datTim2 As Date = #1/9/2001#
        ' Assume Sunday is specified as first day of the week.

        Dim result As TimeSpan = (datTim2 - datTim1)

        MsgBox(result.Days)

 

        Dim datTim1 As Date = Me.DateTimePicker2.Value
        Dim datTim2 As Date = Me.DateTimePicker1.Value
        ' Assume Sunday is specified as first day of the week.

        Dim result As TimeSpan = (datTim2 - datTim1)

        MsgBox(result.Days)

问候,

  Thorsten

  Thorsten


这篇关于如何在年,月,日两个日期之间取得差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 08:50