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)
 DateTime to SmallDateTime

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-28 : 06:57:45
Sholana writes "An implicit conversion or so it says!
Data in the field starttime in format 12:30:00 PM note no date!
Client wants field changed from Datetime to smalldatetime ie remove seconds...
So I get an overflow on smalldatetime when I try to change it
Anyone out there know how to overcome this?
Tried importing into new database with convert and cast"

Andraax
Aged Yak Warrior

790 Posts

Posted - 2002-08-28 : 07:04:07
Just use explicit conversion (convert or cast). The below code works fine for me (SQL 2000):

declare @d1 datetime, @d2 smalldatetime

select @d1 = GetDate()

select @d2 = convert(smalldatetime, @d1)

select @d1
select @d2

Result:


2002-08-28 12:56:46.187

2002-08-28 12:57:00




Regards,
Kalle Dahlberg

Go to Top of Page
   

- Advertisement -