将DateTime转换为正确的格式:C#.NET [英] Convert DateTime into proper format : C#.NET

查看:85
本文介绍了将DateTime转换为正确的格式:C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的

我有一个Windows应用程序,带有4个文本框(开始日期和开始时间以及结束日期和结束时间)和存储过程,该过程带有2个参数(开始日期时间和结束日期时间).在数据库中,我有一列具有DateTime数据类型的发票日期.

用户可以选择此格式的开始日期时间和结束日期时间,

开始日期:2013/4/30开始时间:12:00:00 AM

结束日期:2013/4/30结束时间:11:59:59 PM

当用户输入开始日期和结束日期时,他需要获取该时间段之间的发票总数.数据库以yyyy-MM-dd HH:mm:ss.0000(2013-04-30 4:00:00.0000)格式存储的日期时间值,以及用户以yyyy-MM-dd HH:mm:ss格式存储的用户选择日期(2013- 04-30 4:00:00).

如何将用户输入内容转换为正确的格式以获取期望的输出.

谢谢.


Rushabh

解决方案

如果对存储过程使用DateTime值和SQL参数,则 格式没关系.  数据库访问层将为您自动处理-只需将所有内容保留在DateTime中,然后使用即可.


Dear,

I have a windows application with 4 Textbox (Start Date and Start Time and End Date and End Time) and Storage Procedure which takes 2 parameter (Start DateTime and End DateTime). In database, I have have one column Invoice Date with DateTime datatype. 

User can select Start DateTime and End DateTime in this format, 

Start Date: 4/30/2013 Start Time: 12:00:00 AM

End Date: 4/30/2013 End Time: 11:59:59 PM

When User enter start date and end date, he need to get total number of invoice between that time frame. Database stored date time value in yyyy-MM-dd HH:mm:ss.0000 (2013-04-30 4:00:00.0000) format and user select date in yyyy-MM-dd HH:mm:ss format (2013-04-30 4:00:00). 

How to convert user entry into proper format to get desire output. 

Thanks. 


Rushabh

解决方案

If you use DateTime values, and SQL Parameters for your stored procedure, the format shouldn't matter.  The database access layer will automatically handle that for you - just keep everything in DateTime, and use it.


这篇关于将DateTime转换为正确的格式:C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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