如何在asp.net应用程序中处理日期 [英] How to handle date in asp.net application
问题描述
我正在使用asp.net创建一个Web应用程序。我使用ajaxtoolkit:calenderextender作为日期类型文本框。任何人都可以告诉我什么是在日期插入日期到sql server和retrive数据的最佳选项。
I am creating a web application using asp.net.I am using ajaxtoolkit:calenderextender for date type textbox.Can anyone tell me what is the best option to insert date into sql server and retrive data basis on date.
推荐答案
将日期插入sql server和retrive的最佳选择是什么基于日期的数据基础
what is the best option to insert date into sql server and retrive data basis on date
最佳选项使用 DateTime [ ^ ]数据类型。
始终使用适当的数据类型来存储数据以便有效地执行查询
Best option use DateTime[^] datatype.
Always use appropriate datatype to store data in order to perform queries effectively
将数据类型用作日期时间你的桌子
Use the Datatype as Datetime in your table
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtfrom" runat="server" Format="dd/MM/yyyy">
</asp:CalendarExtender>
将日期发送为字符串,如2014-03-03(yyyy-MM- dd)到sp
Sp样本
创建程序样本
@da te varchar(20)
as
开始
//完成
结束
Aspx
Send date as string like "2014-03-03"(yyyy-MM-dd) to sp
Sp sample
Create procedure sample
@date varchar(20)
as
begin
// done
end
Aspx
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtfrom" runat="server" Format="yyyy-MM-dd">
</asp:CalendarExtender>
你可以使用任何格式,但最后你必须转换为'yyyy-MM-dd'格式。
you can use any format but finally you have to convert to this 'yyyy-MM-dd' format.
这篇关于如何在asp.net应用程序中处理日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!