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)
 Convert date to character

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-08-09 : 08:05:34
I need to convert a JDE date to character, have following code that converts to date/time

DECLARE @jde NUMERIC(6, 0)
DECLARE @date as datetime

SET @jde = 110216

set @date = DATEADD(DAY, @jde % 1000, DATEADD(YEAR, @jde / 1000, -1))


Result is Aug 4 2010, I would like to see the character format like 20100804 (yyyymmdd). Thank you.

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-09 : 08:09:33
Add the following code below your code
SELECT CONVERT(VARCHAR(10),@date,112)

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -