Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Below expression returns Jan 2008 to jun 2008. I need to count the no. of month between them:
MonthName(YearStart(Date#( Year(Today())-1, 'YYYY') )) &' to '& month(addmonths(Today(),-1)) &' ' &(Year(Today())-1)
If possible, let me know some other way to calculate no. of months between starting of year to lst month as done above.
Thanks,
Sunil
Wouldn't that be same as number of last month, like 6 for june, since you are always workign with current year only?
If this is correct, you can get that by using: num(month(addmonths(Today(),-1)))
Hope I answered what you are looking for.
Sunil,
Because Months are usually stored as a Dual (meaning they have both a numeric and a text representation) you can actually just subtract them to find the number fo months between them. A work of caution though, this only works if you are staying in the same year. If you are crossing years you must account for that.
So, given your example, something like this should work:
Month(AddMonths(Today(),-1)) - Month(YearStart(Today()))
This will give you the number of months between last month and the start of the year.
Thanks
sjprows
Month(YearStart(Today())) is always 1 so you might hard code it as 1.