Focal Point
[CLOSED] converting date to M/DD/YY

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

November 13, 2017, 08:40 AM
PO
[CLOSED] converting date to M/DD/YY
Trying to convert a date field of MM/DD/YYYY to M/DD/YY

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8105
Windows, Excel
November 13, 2017, 08:47 AM
BabakNYC
PO

Not sure why you would want to chop off the first digit of month since 10, 11, and 12 would not be correct. You can use the following syntax to do that though.


-SET &DTMDDYY=EDIT(&DATEMDYY,'$99999$$99');


Why don't you just use &DATEMDY?

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8206, Unix, Windows
November 13, 2017, 10:10 AM
FP Mod Chuck
Opps I accidentally overlaid BabakNYC's reply. Babak can you re post yours...


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
November 13, 2017, 10:12 AM
BabakNYC
https://webfocusinfocenter.inf...g/source/date127.htm


WebFOCUS 8206, Unix, Windows
November 14, 2017, 10:25 AM
PO
SET &DTMDDYY=EDIT(&DATEMDYY,'$99999$$99');


Why don't you just use &DATEMDY?

I used these in define and they are not working. Did you try the code out previously. Essentially the customer want to suppress the leading zero in the month. 05/05/17 to 5/5/17. Does that help?


WebFOCUS 8105
Windows, Excel
November 14, 2017, 10:36 AM
BabakNYC
Is this for display purposes only or will you try to use this variable in your code? If it's for the former (and this is a show stopper) you can use an IF THEN ELSE statement to first find out if your month and day segments are less than 10 and mask out the 0. If it's for the latter, you will not be able to use the manipulated zero suppressed variable for WHERE tests.

You should find out how important this is though, because you're going to create a lot of extra code to satisfy a pretty minor requirement. Someone down the road will need to decipher this code to figure out why you're doing all this stuff. The labor involved in one variable might not be much but once you make it the standard, every report with a date variable will have to look this way and you're now stuck with a lot of extra coding.


WebFOCUS 8206, Unix, Windows
November 14, 2017, 10:39 AM
Frans
Or if it's in the data just change the format:
 
TABLE FILE EMPLOYEE
PRINT 
HIRE_DATE
HIRE_DATE/MDY AS 'NEW_HIRE_DATE'
WHERE RECORDLIMIT EQ 2
END
 



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
November 14, 2017, 10:49 AM
BabakNYC
Frans, that won't make 05/05/17 into 5/5/17 though.


WebFOCUS 8206, Unix, Windows
November 14, 2017, 10:56 AM
Frans
OK, thereis probably an easier solution, but it works:

TABLE FILE EMPLOYEE
PRINT 
     EMPLOYEE.EMPINFO.HIRE_DATE/MDY
	 COMPUTE ALPHA_HIRE/A17 = EDIT(HIRE_DATE);
	 COMPUTE TST/A8=TRIM('L',REVERSE(8,EDIT(REVERSE(6,CHGDAT('YMD', 'MDY', EDIT(HIRE_DATE), 'A6'),'A6'),'99/99/99'),'A8'),8,'0',1,'A8');
	 WHERE RECORDLIMIT EQ 1
END
  



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
November 14, 2017, 11:01 AM
BabakNYC
So, if I'm given a spec that says all dates should be treated like this, I'd have to inflate the labor by at least 25% because I know that's not the only place a date will be present in a report or chart. I would also feel obligated to inform the client that this could become an expensive indulgence of a really minor matter of taste and try to talk them out of implementing that specification.


WebFOCUS 8206, Unix, Windows
November 14, 2017, 12:08 PM
MartinY
quote:
So, if I'm given a spec that says all dates should be treated like this, I'd have to inflate the labor by at least 25% because I know that's not the only place a date will be present in a report or chart. I would also feel obligated to inform the client that this could become an expensive indulgence of a really minor matter of taste and try to talk them out of implementing that specification.


Totally agree with Babak.
That request doesn't worth the effort and the maintenance that it will need in the future...

Furthermore, manipulating the date as specified may result that all date function won't work anymore without putting back the leading zeros.
Can you image all the work that this change will cause ?...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007