日期数据类型自动在SQL Server中追加时间 [英] date datatype automatically appends time in sql server

查看:79
本文介绍了日期数据类型自动在SQL Server中追加时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在sql server中存储日期时,它会在检索它时自动添加"12:00:00 AM" ...我想知道如何停止它???? plz ....任何帮助... ....

when i m storing a date in sql server it automatically adds "12:00:00 AM" when retrieving it... i wanna know how to stop it?????plz....any help.......

推荐答案

数据类型DATEDATETIME也会附加时间.如果要避免时间,请在需要时将列的数据类型设为VARCHARCAST .

--Amit
Data type of DATE or DATETIME will append the time also. If you want to avoid the time then take data type of the column as VARCHAR and CAST it whenever required.

--Amit


您的意思是在asp.net中,它会自动附加到12:00 AM?

然后试试这个.

You mean in the asp.net, it automatically appends 12:00 AM?

Then try this.

date1.ToShortDateString();



这里的date1是我的datetime对象.

或如果在sql server中,则



Here date1 is my datetimeobject.

or if its in sql server, then

select Convert(varchar(10),date1,101) from tbl_Temp


将列数据类型设置为sql server中的日期.如您的问题所示,现在是日期时间.
set column datatype as date in sql server. as your problem shows currently it is date time.


这篇关于日期数据类型自动在SQL Server中追加时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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