Link to home
Start Free TrialLog in
Avatar of CraigLazar
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
ASKER CERTIFIED SOLUTION
Avatar of joeyw
joeyw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CraigLazar
CraigLazar

ASKER

perfect thanks man