Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,
I need to print current Month,year in the excel using code behind in c#

Ex:payslip the month of April,2012
Posted

You can use yourDateTime.ToString("MM/yyyy") to convert date in required format.
Here is how you Write Data to Excel using C#[^]
 
Share this answer
 
Comments
Martin Arapovic 6-Feb-12 5:57am    
Yes, thats it! Using format strings is right solution.
5!
Tech Code Freak 6-Feb-12 6:35am    
5up!
psgviscom 6-Feb-12 11:37am    
my 5!
Use this, replace DateTime.Now by your date
C#
string dt = DateTime.Now.ToString("MMM, yyyy");
 
Share this answer
 
Try This

CONVERT(DATETIME,'" + string.Format("{0:MM/yyyy}", YourDate.Text) + "',103)

This Will Give You The Date As Per Your Expectation
 
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