Format Date Entered by User to Month/Year

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msarzoza
    New Member
    • May 2015
    • 1

    Format Date Entered by User to Month/Year

    What is the code to take a date (mm/dd/yyyy) entered by the user and formatting it to Month & Year. So for example, if the user enters 1/31/2015 I want to copy it to another cell and format it to show January 2015. If the user enters 1/15/2015 I want it to format also as January 2015.

    Thanks,
    Michelle
  • ayakamacy
    New Member
    • May 2015
    • 14

    #2
    Code:
    Dim now As DateTime = DateTime.Now
    Response.Write("<BR/>" & now.ToString("y"))
    Output : May, 2015

    Comment

    • ayakamacy
      New Member
      • May 2015
      • 14

      #3
      Try this also.

      Code:
      Dim d As Date
      If Date.TryParse(txtDate.Text, d) Then
         Response.Write(d.Month & " - " & d.Year)
      End If

      Comment

      Working...