Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, please can someone tell me how to make a year month column
I am bringing in a field from excel called Anticipated Launch date.
An example of a date being brought in is Apr-15
I want to create a new column with year month in it so would want the above to show as
2015-4
Please can someone help with this issue.
Thank you
Kind Regards
Date(date#([Anticipated Launch date],'MMM-YY'),'YYYY-M)
Date# evaluates a string into a calendar format.
Date formats a calendar value.
Thank you for your help Martin but I still have an issue with it. I am adding this date to a column with a date already in it. They look like the same format but one is right justified and one left:
eg
2014-6
2014-5
2014-5
2014-8
Please could you assist in getting them the same. Thanks
Load
[Launch Date],
Date(MonthStart(Date#([Launch Date],'MMM-YY')),'YYYY-M') as YearMonth
Inline
[
Launch Date
Apr-14
Apr-15
Jun-14
Jun-16
];
Anything that is left aligned is probably formatted as text, right a aligned as number/date.
Make sure the column already with a date in it also has the correct calendar format.
Looks like one is a string and not a numeric date, try something like :
Date(date#([YourDateField],'YYYY-M)','YYYY-M')
Why MonthStart()?
Even without MonthStart() it will work...
Hi Martin
The other date comes in like this
convert(varchar,year([PstngDate])) + '-' + convert(varchar,month([PstngDate])) as yearmonth
Im not sure how to convert this back to match the other one.
......... and apologies,,, im very new to all this!!
Emma
Try something like
date([PstngDate] ,'YYYY-M') as yearmonth ,