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
 General SQL Server Forums
 New to SQL Server Programming
 Datetime into new column Month_year and Day

Author  Topic 

citiinvestor
Starting Member

1 Post

Posted - 2009-09-19 : 19:50:26
This is my SSIS exercise
I have a DATETIME column, what I want is to get the Month and Year from " DATETIME " column and load it into a new column called “Month_Year” and then get day from the same " DATETIME " and load it into a new column called "day"
Visually
1. Source Column:
DATETIME
2. Destination Column:
Month_Year Day
Bottom line is I need to break DATETIME into two column Month_Year and Day.

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-20 : 07:07:32
You can try this in the Derived Column Transformation Editor Expression
Month_Year: (DT_STR,2,1252)DATEPART("mm",GETDATE()) + (DT_STR,4,1252)DATEPART("yyyy",GETDATE())
Day: (DT_STR,2,1252)DATEPART("dd",GETDATE())
Go to Top of Page
   

- Advertisement -