Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a Month column that contains Months value Like this 'January', 'February' and so on. I have a Year field that contains Year Value Like this '2014', '2015' and so on.
I would like to tie this two column and make a date field and then calculate the max date from this field.
The problem is when i concatenate this two field and make one date field i cant calculate max date from that date field. I think the reason behind is, i am concatenating string and number.
Could anyone help me out this problem?
Thanks,
Ahmed100
Try this:
MakeDate(YearField, Num(Month(Date#(MonthField, 'MMMM'))), 1) as Date
I don't think being a number would stop the concatenation. Works fine for me like this:
date#('February ' & 2015,'MMMM YYYY')
So in the script, I'd do something like this:
,date#([Month] & ' ' & [Year],'MMMM YYYY') as [Month Year]
And then just this as the expression:
max([Month Year])
edit: date(max([Month Year],'MMM YYYY')
Hi John, Thanks a lot!
While calculating the max i am getting integer value but if i use date function before max then i am getting date format like this 1/1/2016. but i would like to keep it like Jan 2016.
Thanks again.
Regards,
Ahmed100
Ah, right. Probably this?
date(max([Month Year],'MMM YYYY')
Here is a sample to play around with:
SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';
Table:
LOAD *,
MonthName(Date) as MonthYear;
LOAD *,
MakeDate(Year, Num(Month(Date#(Month, 'MMMM'))), 1) as Date;
LOAD * Inline [
Year, Month, Sales
2014, January, 343
2014, February, 420
2014, March, 492
2014, April, 234
2014, May, 542
2014, June, 432
2014, July, 654
2014, August, 234
2014, September, 323
2014, October, 653
2014, November, 653
2014, December, 658
];
Hi Sunny, for some reason your solution didnt show up before Johns post! . I dont know what happened.
But thank you so much for your help. You have been very helpful before as well.
As long as you get to what you are looking for, we don't mind who get the right answer. If you still feel my answer is useful, you can mark it as a helpful answer (but you don't have to)
Yeah, strange, I didn't see it before I posted either, or even after I posted for quite some time.
(edit: Ah, the forum updates the time when I update the message.)
It popped up from no where? Strange, I was not even put for moderation