在sql数据库中插入日期 [英] Insert date in sql database

查看:126
本文介绍了在sql数据库中插入日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sql数据库中插入日期..

不使用sql参数

How to insert date into sql database..
Without using sql parameters

推荐答案

不要。



始终使用SQL参数 - 它可以消除系统中的任何混淆,并且意味着您的数据始终保持一致:这将消除更严重的问题。



但是......如果你对它们过敏,那就把它作为ISO 8601格式的字符串发送:yyyy-MM-dd

http://en.wikipedia.org/wiki/ISO_8601 [ ^ ]

它是明确的并且显示转换没有问题。如果它是用户输入,请记住验证它!



但请将它存储在Date或DateTime列中 - 不要试图使用NVARCHAR或类似的,它总是以泪水结束......
Don't.

Always use SQL parameters - it removes any confusion from the system and means that your data is always consistent: which removes worse problems further down the line.

But...if you are alergic to them, then send it as a string in ISO 8601 format: yyyy-MM-dd
http://en.wikipedia.org/wiki/ISO_8601[^]
It's unambiguous and show convert without problems. Just remember to validate it if it is a user input!

But please, store it in a Date or DateTime column - don't be tempted to use a NVARCHAR or similar, it always ends in tears...


这篇关于在sql数据库中插入日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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