Tuesday, December 15, 2009

Formatting International Date

A quick post to help establish the numerical designator for a day, and create a International date in the form (DD(designator) MMMM, yyyy).

Code Snippet
  1. Private Function FormatInternationalDate(ByVal DateToFormat As Date) As String
  2.     Dim NumericalDesignator As String = String.Empty
  3.     Select Case Day(DateToFormat)
  4.         Case Is = 1, 21, 31
  5.             NumericalDesignator = "st"
  6.         Case Is = 2, 22
  7.             NumericalDesignator = "nd"
  8.         Case Is = 3, 23
  9.             NumericalDesignator = "rd"
  10.         Case Else
  11.             NumericalDesignator = "th"
  12.     End Select
  13.     '// Return date as 24th June, 2009
  14.     Return DateToFormat.Day.ToString & NumericalDesignator & Space(1) & DateToFormat.ToString("MMMM, yyyy")
  15. End Function

No comments:

Post a Comment

Calling .NET From COM Originally posted by Mikec276 on C Sharp Friends It might be hard to convince your IT manager to let you build y...