日期时间格式MM/yyyy [英] datetime format MM/yyyy

查看:494
本文介绍了日期时间格式MM/yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,
我需要使用c#中后面的代码在excel中打印当前的月,年.
例如:payslip 2012年4月

Dear sir,
I need to print current Month,year in the excel using code behind in c#

Ex:payslip the month of April,2012

推荐答案

您可以使用yourDateTime.ToString("MM/yyyy")将日期转换为所需格式.
这是您使用C#将数据写入Excel的方法 [ ^ ]
You can use yourDateTime.ToString("MM/yyyy") to convert date in required format.
Here is how you Write Data to Excel using C#[^]


使用它,用您的日期替换DateTime.Now
Use this, replace DateTime.Now by your date
string dt = DateTime.Now.ToString("MMM, yyyy");


尝试一下

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

这将按照您的期望给您日期
Try This

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

This Will Give You The Date As Per Your Expectation


这篇关于日期时间格式MM/yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆