dbTalk Databases Forums  

Time Convert

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Time Convert in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Service Tech
 
Posts: n/a

Default Time Convert - 02-08-2004 , 11:22 AM






I have a data source that has a column for Time xx/xx/xxxx which
through DTS i can convert without any issue into the data field. There
is a second column HHmm which is military time. Whenever I try to do a
conversion to datetime i get an error even if I specify the
transformation as a datetime conversion and select the source as HHmm
and destination as hh:mm. If any one has any ideas I would appreciate
it I have been beating my head against the wall on this one.

TIA

S

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Time Convert - 02-08-2004 , 01:10 PM






This works for me

CREATE TABLE HoldsOnlyTime(TimeVal char(4))
GO
INSERT HoldsOnlyTime VALUES('2004')
INSERT HoldsOnlyTime VALUES('1918')
INSERT HoldsOnlyTime VALUES('0004')
INSERT HoldsOnlyTime VALUES('1902')


CREATE TABLE ConvertedToSmallDateTime(ColTime smalldatetime)

insert ConvertedToSmallDateTime
SELECT CAST(CONVERT(CHAR(8),left(TimeVal,2) + ':' + right(TimeVal,2),108) as
smalldatetime) from HoldsOnlyTime

--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Service Tech" <naughtonservice (AT) yahoo (DOT) com> wrote

Quote:
I have a data source that has a column for Time xx/xx/xxxx which
through DTS i can convert without any issue into the data field. There
is a second column HHmm which is military time. Whenever I try to do a
conversion to datetime i get an error even if I specify the
transformation as a datetime conversion and select the source as HHmm
and destination as hh:mm. If any one has any ideas I would appreciate
it I have been beating my head against the wall on this one.

TIA

S




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.