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
 General SQL Server Forums
 New to SQL Server Programming
 regarding datetime datatype

Author  Topic 

christina_rules
Starting Member

23 Posts

Posted - 2007-05-27 : 02:28:35
i've used datetime to store my date and when i read from the database, it displays 12:00:00am as well!..is there any datatype i can use?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-27 : 02:35:18
No. SQL Server does not have a data type for date only.

You can refer to the following link for more information on datetime
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762
http://www.sql-server-performance.com/fk_datetime.asp


KH

Go to Top of Page

christina_rules
Starting Member

23 Posts

Posted - 2007-05-27 : 03:45:58
oh..let's say even i set the time to midnight, the time still displays doesn't it?..however, i don't want it to be displayed.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-27 : 05:46:55
use. The time will still be there. You can use convert() to remove it for do the formatting in your front end to display the date in the format that you want.


KH

Go to Top of Page

christina_rules
Starting Member

23 Posts

Posted - 2007-05-27 : 21:29:53
thanks, kh..i found something like this on the net "Convert(varchar(10), Create_Date, 101)"..but what is 101?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-05-27 : 22:13:31
It's style code, displays date in mm/dd/yyyy format.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-05-27 : 23:33:05
I have a dim recollection of reading somewhere that SQL Server 2008 will finally have separate date and time types, but I can't find the link where I read that.


www.elsasoft.org
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2007-05-28 : 00:18:20
quote:
Originally posted by christina_rules

thanks, kh..i found something like this on the net "Convert(varchar(10), Create_Date, 101)"..but what is 101?




Lookup CONVERT in "Books Online" (in Query Analyzer, click {Help}{Transact-SQL Help}) for a whole list of canned date conversions including the "101".

--Jeff Moden
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2007-05-28 : 00:20:48
quote:
Originally posted by jezemine

I have a dim recollection of reading somewhere that SQL Server 2008 will finally have separate date and time types, but I can't find the link where I read that.


www.elsasoft.org



I guess I'll never understand why people need such a thing when the coversions we all know so well work so well. And, if it's something that needs to be done often for a given table, why don't folks just add a calculated column to the table with the appropriate conversion?

--Jeff Moden
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-05-28 : 02:21:02
that's sort of like saying you don't understand why anyone would need tinyint, smallint, or int when we have bigint. the point is, sometimes datetime/smalldatetime is just not appropriate for the data being stored. so it wastes space, just as bigint would if you used it to store what really ought to be a tinyint.

date would be appropriate for Columns like Birthday, etc.

time would be appropriate for Columns like WhenToGetUpInTheMorning, etc.




www.elsasoft.org
Go to Top of Page
   

- Advertisement -