什么是SQL Server的文化中立日期格式 [英] What is the culture neutral dateformat for SQL Server

查看:87
本文介绍了什么是SQL Server的文化中立日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我的编程生涯开始以来,我就有这个问题。 sql服务器中是否确实存在针对日期时间的文化中立格式,以便每当我将客户端的查询字符串发送到运行具有不同系统日期时间格式的sql server 2008端的数据库服务器时,如果查询中包含转换为字符串,什么格式不会给我错误。

I have this question since the dawn of my programming career. Is there really a culture neutral format for datetime in sql server so that when ever I'm sending query string from a client side to the database server running sql server 2008 side having different system datetime format, and if the query contains a date converted to a string, what format would not give me an error.

推荐答案

我建议阅读Tibor Karaszi的日期时间数据类型的最终指南

I recommend reading Tibor Karaszi's The ultimate guide to the datetime datatypes.

如果以未分隔的格式或ISO 8601格式输入日期/时间,则可以进行任何配置。

If you input your date/time in unseparated or ISO 8601 format, then you should be fine with any configuration.

Unseparated = 'yyyymmdd hh:mm:ss'
ISO 8601    = 'yyyy-mm-ddThh:mm:ss'

更新(来自评论):

如果您只需要输入日期(没有时间部分),那么您必须使用'YYYYMMDD'格式,如'Y YYY-MM-DD’不起作用。有关示例,请参见链接文章。

If you need to enter a date only (without the time part), then you have to use the 'YYYYMMDD' format, as 'YYYY-MM-DD' will not work. See the linked article for an example.

这篇关于什么是SQL Server的文化中立日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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