Split Datetime column from ODS (e.g sql, excel and notepad) into Year, month, day, hr, sec, etc
I have a project on Data warehouse and On ETL phase I also want to get datetime from a data source table column and split that datetime column into year, month, day, hr, sec, etc
Example
I have a datime column and in it suppose date and time is "2011-05-01 12:55:45" on ETL I want to split this datetime record and want to put them in multiple columns
like
2011 goes to year column
05 goes to month column
01 goes to date column
12 goes to hr column
55 goes to min column
45 goes to sec column etc
How can I do it please tell me As soon as Possible
regards
Tahir.
September 29th, 2011 3:17am
You can write a Query to include SQL functions to achive this. I have taken [DOJ] as a datatime column for example.
SELECT YEAR([DOJ]) as 'Year',
Month([DOJ]) as 'Month'
,DatePart(hh,[DOJ]) as 'Hour'
,DatePart(mm,[DOJ]) as 'Minute'
,DatePart(ss,[DOJ]) as 'Second'
from TableName
-Vikash Kumar Singh
www.singhvikash.blogspot.com
~ vikash
Free Windows Admin Tool Kit Click here and download it now
September 29th, 2011 4:23am
Hi,
If you don't want to do it in a query... Use derived column transformation and build and expression for every attribute you wanted.
The expression should look something like this
DAY : (DT_WSTR,2)DAY(GETDATE())
YEAR : (DT_WSTR,2)YEAR(GETDATE())
and so on....
If the post helps, mark it as answer.
Regards,
Indraneel A
September 29th, 2011 5:11am