By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

Format Date Entered by User to Month/Year

P: 1
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
May 21 '15 #1
Share this Question
Share on Google+
2 Replies


ayakamacy
P: 14
Expand|Select|Wrap|Line Numbers
  1. Dim now As DateTime = DateTime.Now
  2. Response.Write("<BR/>" & now.ToString("y")) 
  3.  
Output : May, 2015
May 23 '15 #2

ayakamacy
P: 14
Try this also.

Expand|Select|Wrap|Line Numbers
  1. Dim d As Date
  2. If Date.TryParse(txtDate.Text, d) Then
  3.    Response.Write(d.Month & " - " & d.Year)
  4. End If
  5.  
May 23 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.