BOB: Business Objects Board
Not endorsed by or affiliated with SAP

Register | Login 

 
Lead By Knowing (Opens a new window)  

General Notice: No events within the next 45 days.

INT to DATE - SQL Server 2008


 
Search this topic... | Search DI: Designer and Job Design... | Search Box
Register or Login to Post    Forum Index -> Data Integrator -> DI: Designer and Job Design  Previous TopicPrint TopicNext Topic
Author Message
ganeshxp
Forum Addict
Forum Addict



Joined: 17 Jul 2008
ASUG Icon
Posts: 3671
Location: Denver, Colorado, USA


flag
PostPosted: Tue Jul 31, 2012 2:01 pm 
Post subject: INT to DATE - SQL Server 2008

Hi

I am trying to convert a DATE in INT Format (YYYYMMDD) to a DATE Format

In the Query, I applied
TO_DATE(INT_DATA_COLUMN.'YYYYMMDD')

something like below in a SQL Server code -
SELECT CONVERT(date, 19991212 , 112) DT_COL;

Now the SQL Server is telling - 'Explicit conversion from data type int to date is not allowed.'

However if I do - SELECT CONVERT(date, '19991212' , 112) DT_COL;
by giving the DATE in Quotes, then it is varchar and it converts successfully

How to best handle this? I saw CAST() in documentation. The matrix is not giving a 'X' mark for INT to DATE which means it is not possible...?

_________________
Cheers
Ganesh
Back to top
Arun.K
Forum Associate
Forum Associate



Joined: 18 Oct 2011

Posts: 699
Location: Glen Allen, Virginia


flag
PostPosted: Tue Jul 31, 2012 2:58 pm 
Post subject: Re: INT to DATE - SQL Server 2008

Have you tried converting first to varchar and from varchar to date using to_date function?

Arun
Back to top
ganeshxp
Forum Addict
Forum Addict



Joined: 17 Jul 2008
ASUG Icon
Posts: 3671
Location: Denver, Colorado, USA


flag
PostPosted: Tue Jul 31, 2012 2:59 pm 
Post subject: Re: INT to DATE - SQL Server 2008

Haha you got me. I fixed it that way...But wanted to check what everyone thinks on it?
_________________
Cheers
Ganesh
Back to top
Arun.K
Forum Associate
Forum Associate



Joined: 18 Oct 2011

Posts: 699
Location: Glen Allen, Virginia


flag
PostPosted: Tue Jul 31, 2012 3:38 pm 
Post subject: Re: INT to DATE - SQL Server 2008

thumbsup.gif
Back to top
Display posts from previous:   
Register or Login to Post    Forum Index -> Data Integrator -> DI: Designer and Job Design  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 5 Hours
 
Jump to:  

Index | About | FAQ | RAG | Privacy | Search |  Register |  Login 

Get community updates via Twitter:

Not endorsed by or affiliated with SAP
Powered by phpBB © phpBB Group
Generated in 0.0962 seconds using 17 queries. (SQL 0.0025 Parse 0.0851 Other 0.0086)
CCBot/2.0 (http://commoncrawl.org/faq/)
Hosted by ForumTopics.com | Terms of Service
phpBB Customizations by the phpBBDoctor.com
Shameless plug for MomentsOfLight.com Moments of Light Logo