开发者

How to get the Time value from datetime picker

How to get the time value in a stored procedure from a DateTimePicker value?

For Example:

I have a datetime picker value stored into my table as:

'2010-04-06 09:00:00.000' 
'2010-04-07 14:30:00.000'
  • I have to get the date seperately using Convert(varchar,Date,3) as Date
  • I have got the time seperately using Convert(time,Time)

But it show the values as 9:00 or 14:30

I need it to show them as 9:00AM and 2:30PM instead of 14:30.开发者_JAVA技巧


You can use yourDate.ToString("t");.
Also check other formats


try something like that:

date.ToString("hh:mm tt", CultureInfo.InvariantCulture);


to get current time you can use

now.toshorttime()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜