Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Display date only

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2007-05-03 : 14:15:57
I use code:

dateadd(day, datediff(day, 0, @date), 0)

to display date only. It works fine in SQL 2000.

But, in SQL 2005, it coming "12:00 AM" as well.

How to fix it without time part but still keep datetime data type?

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-03 : 14:29:40
Don't start new threads when people are trying to help you elsewhere.

As I wrote before:

A DateTime value ALWAYS has a time, that's why it is called datetime. Do not worry about what Query Analyzer or Management Studio displays when writing your code, worry about the data itself. Your front end -- reporting tool, client application, web page, etc -- can format that DateTime any way that it wants very easily with great flexibility. What front end are you using? Where is this data ultimately displayed?


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2007-05-03 : 14:46:30
if you convert it eg

convert(varchar(8),@date,103) then it does take the time off

but as jsmith8858 said I would leave that to the the front end application not something to be bothered about in the database and what is the requirement to take the time of anyway.
Go to Top of Page
   

- Advertisement -