Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Can any one simplify the formula please.
VDate is a variable and the values can be 201506
=MakeDate( Left(Purgechar(vDate,Chr(39)),4),Right(Purgechar(vDate,Chr(39)),2))
Thank you.
This worked for me if you don't need a day:
=Date(Date#(vVar, Chr(39)&'YYYYMM'&Chr(39)), 'MMM-YYYY')
If you just need to convert your variable into a date you can use this:
=Date#(vDate, 'YYYYMM')
But if you need a day as well then you will have a big formula like this:
=MakeDate(Year(Date#(vDate, 'YYYYMM')), Month(Date#(vDate, 'YYYYMM')), 2)
HTH
Best,
Sunny
Another look at your formula, why are you purging Chr(39)? You variable doesn't seem to have any single quotes in it?
What is the value in your vDate variable, do you have special characters which you are removing by using purgechar.
I Can't edit variable as it was already created in a application. I just adding an expression in a chart by using this variable.
Sorry actually the variable contains year and month like '201505', so I am using purgechar syntax.
Yes Ankita. The variable contains single quotes at the starting and end of the string.
Sunindia is Right, No need to use purge char,Use like this
=MakeDate( Left('2001/11/11',4),Right('2001/11/11',2))
If your vDate = '2001/11/11'
Thanks,
Vikram.
=Date(MakeDate( Left(vDate,4),Right(vDate,2)),'MMYYYY')
This worked for me if you don't need a day:
=Date(Date#(vVar, Chr(39)&'YYYYMM'&Chr(39)), 'MMM-YYYY')
If you want to create the whole date then
=MakeDate(mid($(vDate),1,4),mid($(vDate),5,6),01)
or if you just want YYYY-MM then
=Date(Date#($(vDate),'YYYYMM'),'MM/YYYY')