VB.NET DateSpan Class

Tired of writing code to find the years and months between two dates?

”’ <summary>

”’ Provides an easy way to get the number if years and months bewteen two dates.

”’ </summary>

”’ <remarks></remarks>

Public Class DateSpan

   Dim _Years As Integer

   Dim _Months As Integer

 

 

   Public Sub New(ByVal StartDate As Date, ByVal EndDate As Date)

 

      Dim intTotalMonths As Integer = DateDiff(DateInterval.Month, StartDate, EndDate)

 

      _Years = intTotalMonths \ 12

      _Months = intTotalMonths – (_Years * 12)

   End Sub

 

   Public ReadOnly Property Years() As Integer

      Get

         Return _Years

      End Get

   End Property

 

 

   Public ReadOnly Property Months() As Integer

      Get

         Return _Months

      End Get

   End Property

 

End Class

Political Comments on March 25, 2008

Clinton
Admits that she ‘Misspoke’ about her trip to Bosnia. Either you intentionally embellished (lied?) about the trip, you forgot what happened, or you believe something happened and it didn’t. In any of those cases it’s not something I would expect in my future President.

How to Get the Date of a DateTime in SQL Server

Pretty simple really. Try this SQL:

SELECT CONVERT(nvarchar(20), GetDate(), 101);

or

SELECT CONVERT(nvarchar(20), CAST(‘2008-04-04 16:07:07.920’ AS DateTime), 101);

If you need to use it in a comparison you can easily do something like

WHERE CONVERT(nvarchar(20), MyDateColumn, 101) BETWEEN @DateFrom AND @DateTo

Enjoy!