CraigLazar
asked on
Strip Month and year from date column for new column
Hi,
I need to simply create a new column in a select statement based off the current columns.
Derived column is called xNew
and needs to be made up of the following Date1.MM + Date1.YY
i am using the cast statement
Date1 = 2010/03/06
i need column Newx to = 0310
i am using the datepart function to but it is not giving me a leading 0 infront of the 3
(hope this makes sense)
select CAST(datepart(MONTH,Date1) as varchar(2)) + CAST(datepart(YYYY,Date1) as varchar(2)) as xNew from tmpTable
thanks
I need to simply create a new column in a select statement based off the current columns.
Derived column is called xNew
and needs to be made up of the following Date1.MM + Date1.YY
i am using the cast statement
Date1 = 2010/03/06
i need column Newx to = 0310
i am using the datepart function to but it is not giving me a leading 0 infront of the 3
(hope this makes sense)
select CAST(datepart(MONTH,Date1)
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER