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 2000 Forums
 SQL Server Development (2000)
 What data type only list date without time?

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2006-02-20 : 15:10:00
I use smalldatetime to store date data but displays like 'mm/dd/yyyy, 12:00 AM". What data type only list date without time, like 'mm/dd/yyyy'?

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-02-20 : 15:14:18
There is no datatype that holds date without time. SmallDateTime is just a smaller daterange than DateTime. Check out datatypes in BOL for the exact range.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-20 : 17:25:17
use convert(varchar(10), yourdate, 101)

----------------------------------
'KH'

Time is always against us
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-02-20 : 17:34:07
this method works. It just sets the time portion to midnight


SELECT DATEADD(d,DATEDIFF(d,0,GETDATE()),0)




-ec


Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-02-20 : 17:35:08
btw, I assume you are asking this so that you can do some kind of comparison on just the date portion of a datetime field. Is that a correct assumption?



-ec
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-20 : 18:35:50
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Round+a+date+to may help

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-21 : 00:59:00
>>SELECT DATEADD(d,DATEDIFF(d,0,GETDATE()),0)

Just for clarity I prefer to use

SELECT DATEADD(day,DATEDIFF(day,0,GETDATE()),0)

sun Foster, where do you want to show the date without time?
If you use Front End application, use the format function there


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -