在SQL Server中以dd-mm-yyy格式显示日期 [英] display date in dd-mm-yyy format in SQL server

查看:182
本文介绍了在SQL Server中以dd-mm-yyy格式显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我正在asp.net中从事员工管理项目,并且我需要从正面(asp.net)以DD_MM_YYYY格式存储日期,例如textbox1 [28-11-2009]到后手表...
先生,请给我解决方法,这样我就可以继续工作...!
谢谢,
by-
塔库尔·沙玛
mca vth sem.

sir, i am working on employee management project in asp.net and i need to store date in DD_MM_YYYY format from front-hand(asp.net) e.g. textbox1[28-11-2009] to back-hand table...
sir please give me solution so, i can my work in continue way...!
thanks,
by-
thakur sharma
mca vth sem.

推荐答案

Don''t.

而是在后端代码中将日期转换为DateTime并将DateTime传递给SQL-这样,您就可以使用用户当前的区域性来转换日期.如果您尝试在SQL中进行转换,那么如果用户弄错了数据或使用了您不熟悉的区域性,转换将失败.在代码中执行此操作可以使您更好地定位错误消息!
Don''t.

Instead, convert the date to a DateTime in the back end code and pass the DateTime to the SQL - that way you can use the users current Culture to convert the date. If you try to do the conversion in the SQL, then it will fail if the user gets the data wrong, or uses a culture you are not familiar with. Doing it in your code allows you to better target the error message!


这篇关于在SQL Server中以dd-mm-yyy格式显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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