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
 Other SQL Server Topics (2005)
 SqlServer datatype

Author  Topic 

somaaahmed
Starting Member

1 Post

Posted - 2009-03-25 : 13:50:22
this my first post here and i wanna help

I make atable in sqlserver2005 , i choose datatype datetime for col but wanna store data as date only in col without time how can i make that ?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-03-25 : 14:19:33
Best thing to do is have your user interface strip the time off of the value. Otherwise you'd have to write a trigger to update the column to remove the time. Better do that as a last resort.

Keep in mind a datetime/smalldatetime always have a time component, storing a "date only" means the time is set to midnight.
Go to Top of Page

BJM RAO
Starting Member

20 Posts

Posted - 2009-04-01 : 12:58:53
if already declared u should convert it the way u wish
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-01 : 13:29:18
just insert only date values to your table. even if you're using functions like GETDATE() .... strip off timepart using DATEADD(dd,DATEDIFF(dd,0GETDATE()),0).... then your column will have timepart always as 00:00:00.000 then in front end use format functions to remove this part.
Go to Top of Page
   

- Advertisement -