修剪日期时间 [英] Trim the date Time

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

问题描述



我需要转换日期时间,所以我只使用了转换功能并获取日期.但是我需要时间,所以那里有什么方法吗?

谢谢

Hi,

I need to convert date time so i used convert function and getting date only. but i need time so is there any method is there.

Thanks

推荐答案

请参见此处 [ ^ ]可获得的参数列表您可以将其与Convert方法一起使用.选择所需的参数.
See here[^] for a list of parameters that you can use with the Convert method. Choose the parameter that you require.


在转换"中使用以下参数来获取时间
Convert(NVARCHAR,< field_name>,108)
Use the Following Parameters in Convert to get time
Convert(NVARCHAR,<field_name>,108)


是的,请使用TimeOfDay属性.它给出了时间分量.

Yes, use TimeOfDay property. It gives the time component.

DateTime dt = new DateTime();
            dt = Convert.ToDateTime("12/11/2009 14:34:56");
            string sr = dt.Date.ToString();
            string st = dt.TimeOfDay.ToString();



输出:sr ="2009年12月11日12:00:00"
st ="14:34:56"



Output : sr = "12/11/2009 12:00:00"
st = "14:34:56"


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

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