Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want my date in a particular foramt ie. MMM YYYY, meaning for present date I should get APR 2011.

Please tell me which function to use.
Posted
Updated 13-Apr-11 21:26pm
v2
Comments
Dalek Dave 14-Apr-11 3:26am    
Edited for Grammar and Readability.

try this link

ClickHere[^]
 
Share this answer
 
Comments
walterhevedeich 14-Apr-11 2:48am    
Good link. voted 5
Mahendra.p25 14-Apr-11 2:54am    
Thanks
Dalek Dave 14-Apr-11 3:26am    
Spot on!
I would suggest that you did this in the end App, as it is a presentation feature rather than a back end, and it it slightly simpler to use.

However, for SQL:
SQL
SELECT DATENAME(MONTH, date) + ' ' + DATENAME(YEAR, YEAR(date)) AS Date FROM myTable


In .NET it is easier and cleaner once you have read out the date into a DateTime:
string myDateString = myDate.ToString("MMM yyyy");


There is a list of .NET DateTime.ToString formattoing codes here: Formatting a DateTime for display - format string description[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900