Focal Point
[CLOSED]Extract year from the date amper variable

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

December 23, 2014, 04:59 AM
info4pal
[CLOSED]Extract year from the date amper variable
Hi,

Iam using sql passthrough and later Iam trying to read the amper variables and one among those amper variable is a date field which looks something like this:
&date=2011001

I need to extract only the year part from this date amper variable and I was not successful in getting this done using either the Edit nor other date functions.

Any help on how to do this would be much appreciated!

Thanks a lot in advance!

Regards!

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


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
December 23, 2014, 05:15 AM
Ram Prasad E
There are multiple options available. Since it is from DB, default column format will be in date. So either use DB functions to extract year from date and then read it in WebFOCUS or you can use WF functions to convert Date format to alpha and then read into amper variable.

I prefer DB conversion as it is simple and straight forward .
Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
December 23, 2014, 05:25 AM
info4pal
Hi Ram,

Thanks a lot for the quick response but I actually cannot change it in the DB.
Is there any other ways to get it done in Webfocus.

Any sample example on this might be helpful.

Thanks a lot!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
December 23, 2014, 05:52 AM
info4pal
Hi,

The format of the field is D20.2 and not date.

Regards1


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
December 23, 2014, 06:12 AM
info4pal
I got the solution!Thanks!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
December 23, 2014, 06:19 AM
Ram Prasad E
You can try either of these.
-SET &DATE_YYMD=20141225;
-SET &DATE_YY=&DATE_YYMD/10000;
-TYPE DATE_YY - &DATE_YY
-EXIT
TABLE FILE CAR
SUM
COMPUTE DATE_YYMD/D20.2=20141225; NOPRINT
COMPUTE DATE_YY/I4=DATE_YYMD/10000;
BY HIGHEST 1 COUNTRY NOPRINT
ON TABLE HOLD FORMAT ALPHA
ON TABLE SET HOLDLIST PRINTONLY
END
-RUN
?FF HOLD
-READ HOLD &DATE_YY.A4.
-TYPE DATE_YY - &DATE_YY




WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
December 23, 2014, 06:57 AM
info4pal
Hi,

Thanks a lot Ram.It helped!

Regards!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML