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)
 User defined data type question

Author  Topic 

skiabox
Posting Yak Master

169 Posts

Posted - 2008-11-05 : 04:31:28
Using this article http://weblogs.sqlteam.com/jeffs/jeffs/jeffs/jeffs/archive/2007/10/31/sql-server-2005-date-time-only-data-types.aspx

I have created the two new user defined datatypes that the article describes in my database and then I altered a table that I am using
and I changed one of its columns from DateTime datatype to Date.
The problem is that I still see the time and if I enter a new record I see again the time after the date.
Any ideas?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-05 : 04:45:35
can you show us the script used to create them?
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2008-11-05 : 04:53:15
create type Date from dateTime
create type Time from dateTime

create rule DateOnlyRule as
dateAdd(dd,datediff(dd,0,@DateTime),0) = @DateTime

go

create rule TimeOnlyRule as
datediff(dd,0,@DateTime) = 0

go

EXEC sp_bindrule 'DateOnlyRule', 'Date'
EXEC sp_bindrule 'TimeOnlyRule', 'Time'


And of course all this script is running against a specific database
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2008-11-05 : 08:41:08
Any ideas visakh16?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-05 : 11:10:55
The time is set to 00:00:00.000 because the datatype is still datetime.
But the time part is "stripped" to 12 am.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -