Is there a way to split dates into int value year, month, and day and then insert them into SQL server DB using SSIS ?
CodePudding user response:
You can use functions, YEAR(), MONTH(), DAY()
Ex:
DECLARE @date datetime2 = '2022-03-09';
SELECT
DAY(@date) AS DAY,
MONTH(@date) AS MONTH,
YEAR(@date) AS YEAR;
DAY | MONTH | YEAR |
---|---|---|
9 | 3 | 2022 |
Reference :
- https://docs.microsoft.com/en-us/sql/integration-services/expressions/year-ssis-expression?view=sql-server-ver15
- https://docs.microsoft.com/en-us/sql/integration-services/expressions/month-ssis-expression?view=sql-server-ver15
- https://docs.microsoft.com/en-us/sql/integration-services/expressions/day-ssis-expression?view=sql-server-ver15
CodePudding user response:
You can use derived column transformation with the built-in date and time functions as follows:
DAY([date_column])
MONTH([date_column])
YEAR([date_column])
Also, you can use the DATEPART()
function as follows:
DATEPART( "day", [date_column] )