Focal Point
[CLOSED] Moving Date to Beginning of a year

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

December 12, 2019, 03:29 PM
John Coleman
[CLOSED] Moving Date to Beginning of a year
I am trying to get two dates, (1) Today's date and (2) the start of the previous year (so 1/1/2018 as of today's date).

Here is what I have so far:

DEFINE FILE car
ED_DT/YYMD= '&DATEYYMD';
PV_YR/YYMD = DATEADD(ED_DT,'Y', -1)
ST_DT/YYMD = DATEMOV(PV_YR,'BOY')
END

The calls for ED_DT and PV_YR work as expected, and return 20191212 and 20181212 respectively. Its when I add the ST_DT line to move the 20181212 to 20180101 using DATEMOV, I get an error that says:

ERROR AT OR NEAR LINE 5 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC224) SYNTAX ERROR: ST_DT

ERROR AT OR NEAR LINE 12 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: PV_YR
(FOC009) Request failed validation, not executed.

I cannot figure its anything other than I can't do DATEMOV in a DEFINE FILE. Is that correct?

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


John Coleman
WEBFocus 8.1.05
Windows 7
December 12, 2019, 03:49 PM
pav
John

You were missing the " ; "

 

PV_YR/YYMD = DATEADD(ED_DT,'Y', -1);
ST_DT/YYMD = DATEMOV(PV_YR,'BOY');

 

December 12, 2019, 03:52 PM
John Coleman
I promise I have been doing this for more than a day, I swear! Thanks


John Coleman
WEBFocus 8.1.05
Windows 7
December 12, 2019, 04:01 PM
pav
That's how you learn anything.
Thank you.
December 12, 2019, 04:33 PM
BabakNYC
I've bookmarked this page. It's where I go to find the syntax for any of these functions.

https://webfocusinfocenter.inf...urce/func_opener.htm


WebFOCUS 8206, Unix, Windows
December 13, 2019, 02:40 AM
Frans
also keep in mind that there are some new date time functions that will be better optimized to SQL, resulting in better performance.

 
DEFINE FILE car
ED_DT/YYMD= DT_CURRENT_DATE();
PV_YR/YYMD = DTADD(ED_DT, YEAR , -1);
ST_DT/YYMD = DTRUNC(PV_YR, YEAR);
END

 



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.