Home > Blockchain >  splitting date into year month day SQL server
splitting date into year month day SQL server

Time:03-10

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 :

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] )
  • Related