出生日期字段的格式? [英] formatting for a birth date field??
问题描述
你好,我是SQL Server的新手,正在为一个非营利性的计算机化一个
的大量数据。
我导入了一个将人名,出生日期等表格放入SS2005
来自Access,并将birth_date导入为访问日期/时间
字段,给它SQL中的datetime数据类型。
列值如下:
10/14/1964 12:00:00 AM
我在哪里以及如何学习如何指定所有这样的字段应该是ISO格式的yyyy-mm-dd的
我是否必须创建一个新列并将所有日期放入其中?
我应该只转换查询/视图中的数据吗?
使用格式化数据的约束??
如果需要,我可以重做Access表,它只有300行。
我试过BOL但是它没有帮助...
最终用户可能会输入mm / dd / yy或mm / dd / yyyy,它将有
存储支柱在数据库表中作为列/字段确实
birth_date ...
Hello, I''m new to SQL Server, working for a non-profit computerizing a
lot of its data.
I imported a table of people''s names, birth dates, etc. into SS2005
from Access, and the birth_date was imported as an Access date/time
field, giving it the datetime datatype in SQL.
The column values look like:
10/14/1964 12:00:00 AM
Where and how do I learn to specify that all fields like this should be
in ISO format of yyyy-mm-dd??
Do I have to create a new column and put all the dates into it??
Should I just convert the data in queries/views??
Use a constraint to format the data??
I can redo the Access table if necessary, it is only 300-some rows.
I tried BOL but it was not helpful...
The end users will likely enter mm/dd/yy or mm/dd/yyyy and it will have
to be stored properly in the database table as column/field
birth_date...
Thank you, Tom
推荐答案
tlyczko写道:
tlyczko wrote:
你好,我是SQL Server的新手,为非盈利计算机化工作
很多数据。
我在SS2005中输入了一个人名,出生日期等表格
来自Access,并将birth_date导入为访问日期/时间
字段,为其提供SQL中的datetime数据类型。
列值看起来像:
10/14/1964 12:00:00 AM
我在哪里以及如何学习如何指定所有这样的字段应该是
的ISO格式的yyyy-mm-dd ??
我是否必须创建一个新列并将所有日期放入其中??? br />
我应该只转换查询/视图中的数据吗?
使用约束来格式化数据??
我可以重做Access如果有必要的话,它只有300行。
我试过BOL但它没有帮助...
最终用户可能会输入mm / dd / yy或mm / dd / yyyy,它将
作为列/字段正确存储在数据库表中
birth_date ...
谢谢Tom
Hello, I''m new to SQL Server, working for a non-profit computerizing a
lot of its data.
I imported a table of people''s names, birth dates, etc. into SS2005
from Access, and the birth_date was imported as an Access date/time
field, giving it the datetime datatype in SQL.
The column values look like:
10/14/1964 12:00:00 AM
Where and how do I learn to specify that all fields like this should be
in ISO format of yyyy-mm-dd??
Do I have to create a new column and put all the dates into it??
Should I just convert the data in queries/views??
Use a constraint to format the data??
I can redo the Access table if necessary, it is only 300-some rows.
I tried BOL but it was not helpful...
The end users will likely enter mm/dd/yy or mm/dd/yyyy and it will have
to be stored properly in the database table as column/field
birth_date...
Thank you, Tom
DATETIME列没有任何特定格式。 SQL Server无法控制客户端应用程序显示的日期格式。
为此,您必须使用客户端应用程序或开发的功能
environment.Typically这些可能基于Windows控制面板中定义的区域格式
。
-
大卫Portas,SQL Server MVP
只要有可能,请发布足够的代码来重现您的问题。
包含CREATE TABLE和INSERT语句通常会有所帮助。
说明您正在使用的SQL Server版本,并指定任何错误消息的内容
。
SQL Server联机丛书:
http://msdn2.microsoft。 com / library / m ... S,SQL.90).aspx
-
A DATETIME column doesn''t have any specific format. SQL Server cannot
control the format of dates as displayed by your client application.
For that you have to use the features of your client app or development
environment.Typically these might be based on the regional format
defined in Windows Control Panel.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--
On 2006年9月16日06:12:07 -0700,tlyczko写道:
On 16 Sep 2006 06:12:07 -0700, tlyczko wrote:
>您好,我是SQL Server的新手,正在为一个非营利性的计算机化大量数据。
>Hello, I''m new to SQL Server, working for a non-profit computerizing a
lot of its data.
(剪辑)
(snip)
>我在哪里以及如何学习指定所有这样的字段应该是ISO格式的yyyy-mm-dd ??
>Where and how do I learn to specify that all fields like this should be
in ISO format of yyyy-mm-dd??
(剪辑)
(snip)
>最终用户可能输入mm / dd / yy或mm / dd / yyyy它将
以列/字段的形式正确存储在数据库表中
birth_date ...
>The end users will likely enter mm/dd/yy or mm/dd/yyyy and it will have
to be stored properly in the database table as column/field
birth_date...
嗨汤姆,
阅读Tibor Karaszi的文章日期时间的终极指南
数据类型,你就会知道你需要知道的一切在SQL Server数据库中安全使用
日期时间:
http://www.karaszi.com/SQLServer/info_datetime.asp
-
Hugo Kornelis ,SQL Server MVP
Hi Tom,
Read Tibor Karaszi''s article "The ultimate guide to the datetime
datatypes", and you''ll know everything you need to know for safely using
datetimes in SQL Server databases:
http://www.karaszi.com/SQLServer/info_datetime.asp
--
Hugo Kornelis, SQL Server MVP
David Portas写道:
David Portas wrote:
DATETIME列没有任何具体的格式。 SQL Server无法控制客户端应用程序显示的日期格式。
为此,您必须使用客户端应用程序或开发的功能
environment.Typically这些可能基于Windows控制面板中定义的区域格式
。
只要有可能,请发布足够的代码来重现您的问题。
包含CREATE TABLE和INSERT语句通常会有所帮助。
说明您正在使用的SQL Server版本,并指定任何错误消息的内容
。
A DATETIME column doesn''t have any specific format. SQL Server cannot
control the format of dates as displayed by your client application.
For that you have to use the features of your client app or development
environment.Typically these might be based on the regional format
defined in Windows Control Panel.
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
我通过SSMS 2005查看表本身,我确实指定了
以上我正在使用的服务器,没有错误消息,它
是使用向导的导入,但我会记得下次创建/插入
等项目。
谢谢你,汤姆
I was looking at the table itself through SSMS 2005, I did specify
above which server I was working in, there were no error messages, it
was an import using the wizard, but I''ll remember the create/insert
etc. items next time.
Thank you, Tom
这篇关于出生日期字段的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!