Focal Point
[SOLVED]How can I convert month, year (Apr, 17) to 04/17?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8787091686

April 20, 2017, 04:40 PM
MelissaReed
[SOLVED]How can I convert month, year (Apr, 17) to 04/17?
I have looked through every possible date function and can't figure this one out. I have an input value of Month Name, Year (IE: Apr, 17). I need to convert that to a date (either 04/17 or even 04/01/17) so I can compare it against a date field. Any ideas?

TIA!

This message has been edited. Last edited by: MelissaReed,


WebFOCUS 8.0.09
Windows, All Outputs
April 21, 2017, 03:06 AM
Balakrishnan Palanisamy
Hi,

Guess it might help you... Not sure which format you are getting.. If you let me know the format as well then i can give you the exact coding.

Hope this works for you.
TABLE FILE CAR
PRINT
COMPUTE
Date/HYYMD = DT(2009 APR 01) ;
Date1/HYYM = DT(2009 APR) ;
Date2/HMD = DT(APR 01) ;
Date3/HMY = DT(APR 17) ;
BY COUNTRY
END

This message has been edited. Last edited by: Balakrishnan Palanisamy,


WebFOCUS 7x and 8x
Windows, All Outputs
April 21, 2017, 08:14 AM
Hank W.
Where/how are you getting this input value? if its from the HTML front end, theres a plethora of display/actual combos there. If it is coming from somewhere else or input manually? then you need to start with what the incoming format is.


Cheers,
H.

WebFOCUS 8.1.05M
Oracle 11g - DB2
RedHat
April 21, 2017, 08:21 AM
BabakNYC
Please provide us an example of what you're trying to accomplish. Input could mean many things and the answer depends on the context.


WebFOCUS 8206, Unix, Windows
April 21, 2017, 08:37 AM
Doug
Is "Apr, 17" the actual or display format of the field which you want to convert? Whether it's the actual or display format is critical to the solution.

You can find almost 1001 ways to work with dates in WebFOCUS in a book, from IBI, of the same name.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
April 21, 2017, 09:26 AM
Chaudhary
quote:
Apr, 17


Its depend on your use case , but you can get an idea
-SET &DATE = 'Jan,17';
-SET &MONTHNAME=GETTOK(&DATE,&DATE.LENGTH,1,',',&DATE.LENGTH,'A&DATE.LENGTH');
-SET &MONTHYEAR = DECODE &MONTHNAME(Jan '01', Feb '02' Mar '03' Apr '04' May '05' Jun '06' Jul '07' Aug '08' Sep '09' Oct '10' Nov '11' Dec '12')|'/'|GETTOK(&DATE,&DATE.LENGTH,2,',',&DATE.LENGTH,'A&DATE.LENGTH');
-TYPE &MONTHYEAR


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
April 21, 2017, 09:42 AM
MelissaReed
Thank you for the feedback so far. I have a chart (tickets per month/year) that has the x-axis in MtY format which I'm passing to a drilldown report. I'm having trouble with the drilldown using the value and am looking for a better way to modify the incoming value so that I can use it in my where clause for the drilldown. Is there something that will take MtY and change it back to a more useable format?


WebFOCUS 8.0.09
Windows, All Outputs
April 21, 2017, 11:15 AM
BabakNYC
Assuming your drill down report has a WHERE fieldname EQ &VAR, what is the format of fieldname? If you run the drill down report on its own, you should get prompted for &VAR in the above WHERE test. What do you enter to get a successful answer? You have to make sure whatever you pass to &VAR is the format it expects.


WebFOCUS 8206, Unix, Windows
April 21, 2017, 11:17 AM
Hank W.
hmmm... I wonder would it work the actual field being in an usable format and the label you see being in the MtY... or then using a hidden field...


Cheers,
H.

WebFOCUS 8.1.05M
Oracle 11g - DB2
RedHat
April 21, 2017, 11:24 AM
MelissaReed
quote:
Originally posted by Hank W.:
hmmm... I wonder would it work the actual field being in an usable format and the label you see being in the MtY... or then using a hidden field...


I've actually done that too, but have run into all kinds of issues when I try using stacked bar charts or multiple series in a bar chart. I'm trying to have a consistent approach regardless of my style of chart (if that is possible).


WebFOCUS 8.0.09
Windows, All Outputs
April 21, 2017, 02:48 PM
MelissaReed
Making progress... I got my input value into 04/01/17 but now I need to transform that into a date value that I can use to compare against my submit date field. No matter which function I try, I end up getting a zero. Any ideas?


WebFOCUS 8.0.09
Windows, All Outputs
April 25, 2017, 12:19 PM
FP Mod Chuck
Hi Melissa

Please share your current code with us so we can provide proper guidance.

Thanks


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
April 25, 2017, 12:29 PM
MelissaReed
-SET &MONTHNAME=GETTOK(&MONTH_YEAR,&MONTH_YEAR.LENGTH,1,',',&MONTH_YEAR.LENGTH,'A3');
-SET &INPUTDATE = '20'|GETTOK(&MONTH_YEAR,&MONTH_YEAR.LENGTH,2,' ',&MONTH_YEAR.LENGTH,'A2')|'/'| DECODE &MONTHNAME(Jan '01', Feb '02' Mar '03' Apr '04' May '05' Jun '06' Jul '07' Aug '08' Sep '09' Oct '10' Nov '11' Dec '12')|'/01/';
-SET &BEGIN_DATE = HCNVRT(HDTTM('&INPUTDATE',8,'HMDYYS'),'(HMDYY)',10,'A10');
-SET &END_DATE = HCNVRT(HDTTM(DATEADD('&INPUTDATE', 'M', 1),8,'HMDYYS'),'(HMDYY)',10,'A10');

This is what I ended up using. It seems to be working pretty good. Thank you Chaudhary for the suggestions


WebFOCUS 8.0.09
Windows, All Outputs
May 12, 2017, 01:56 AM
Chaudhary
quote:
This is what I ended up using. It seems to be working pretty good. Thank you Chaudhary for the suggestions

Smiler


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10