Parsing an integer: Expression for use in populating a derived column
Another solution is, pull all your data into a MS SQL staging table first, and then use T-SQL's COMVERT function to change the date format to whatever you like.
For example, you can use the following query to change your string into 2010-01-12:
CONVERT(datetime, '20100112', 101)
For a full explanation on how to use CONVERT and CAST functions, check this URL:
http://msdn.microsoft.com/en-us/library/ms187928%28v=sql.90%29.aspx
Please mark as answer if this helps. Thank you.
http://thebipalace.wordpress.com
February 26th, 2011 2:07am
Thanks, that helped a lot."I am a Soldier. I fight where I'm told and I win where I fight" GEN George S. Patton, Jr.
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 7:57am
Another solution is, pull all your data into a MS SQL staging table first, and then use T-SQL's COMVERT function to change the date format to whatever you like.
For example, you can use the following query to change your string into 2010-01-12:
SELECT CONVERT(datetime, '20100112', 101)
For a full explanation on how to use CONVERT and CAST functions, check this URL:
http://msdn.microsoft.com/en-us/library/ms187928%28v=sql.90%29.aspxPlease mark as answer if this helps. Thank you.
http://thebipalace.wordpress.com
February 26th, 2011 8:10am
Date column in an imported flat file is in an integer format, 7 or 8 digits, ex: 12012010 or 7032010.
I am replacing that column with a derived column in which I hope to parse out the integer into a date format, ex: 12/01/2011 or 07/03/2010.
My expression thus far:
len(LoginDateTime) <8 ? "0" + SubString(LoginDateTime, 0, 1) + “/” + SubString(LoginDateTime, 1, 2) + “/” + SubString(LoginDateTime, 3, 4) : SubString( LoginDateTime, 0, 2) + “/” + SubString(LoginDateTime,
2, 2) + “/” + SubString(LoginDateTime, 4, 4)
It's not quite working, and I'm hoping something will jump out at the more experienced members here.
Any advice?"I am a Soldier. I fight where I'm told and I win where I fight" GEN George S. Patton, Jr.
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 9:15am
Take a read of
Converting Strings to Dates in the Derived Column Component - that'll clarify things.
Talk to me now on
February 26th, 2011 9:21am