如何在数据库中节省时间我正在使用SqlYog Enterprise作为C#Windows应用程序中的数据库 [英] how to save Time in a database i am using SqlYog Enterprise as database in c# windows application

查看:108
本文介绍了如何在数据库中节省时间我正在使用SqlYog Enterprise作为C#Windows应用程序中的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要节省数据库时间.我正在使用dateTimePicker并更改
其Format属性为time,而在数据库中,数据类型为time.
我的代码是

I need to save time in database. I am using a dateTimePicker and change
its Format property to time and in database the datatype is time.
My code is

String time=datetimePicker.Value.ToString("hh:mm:ss:tt") and
String time=datetimePicker.Value.ToShortTimeString()


但它无法正常工作.我想另存为"9:00:00:AM".现在它像这样"9:00:00"进行保存.


but its not working properly. I want to save as "9:00:00:AM". Now it save like this "9:00:00".

推荐答案

拜拜,这将为您提供帮助:

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx [ ^ ]

链接摘录的一部分:

Hi, mabye this will help you:

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^]

one exerpt from the link:

DateTime date1 = new DateTime(2008, 4, 10, 6, 30, 0);
Console.WriteLine(date1.ToString("T", 
                  CultureInfo.CreateSpecificCulture("en-us")));
// Displays 6:30:00 AM                       
Console.WriteLine(date1.ToString("T", 
                  CultureInfo.CreateSpecificCulture("es-ES")));
// Displays 6:30:00    


在数据库中将字段名数据类型指定为varchar,那么您将获得9:00:00:AM
试试这个

字符串timee = dtpTime.Value.ToLongTimeString();
give the fieldname datatype as varchar in your database then you will get 9:00:00:AM
try this one

String timee = dtpTime.Value.ToLongTimeString();


这篇关于如何在数据库中节省时间我正在使用SqlYog Enterprise作为C#Windows应用程序中的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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