Start of year formula:
Local Datetimevar dates := CURRENTDATETIME();
Local Datetimevar startfinancialyear;
IF MONTH(dates) IN [1,2,3]
THEN startfinancialyear := (DATESERIAL (YEAR(dates)-1,4,1))
ELSE startfinancialyear := (DATESERIAL (YEAR(dates),4,1));
End of year formula:
Local Datetimevar dates := CURRENTDATETIME();
Local Datetimevar endfinancialyear;
IF MONTH(dates) IN [1,2,3]
THEN endfinancialyear := (DATESERIAL (YEAR(dates),3,31))
ELSE endfinancialyear := (DATESERIAL (YEAR(dates)+1,3,31));
Alteration: The End of year formula gets the last day of the financial year, i.e. 31st March. However, it returns the value for the very start of the day (31/03/xxxx 00:00:00) which when incorporated into a selection formula could potential lead to records logged during that final day being excluded.
A correction would be:
End of year formula (correction):
Local Datetimevar dates := CURRENTDATETIME();
Local Datetimevar endfinancialyear;
IF MONTH(dates) IN [1,2,3]
THEN endfinancialyear := DATEADD("s" , -1, (DATESERIAL (YEAR(dates),4,1)))
ELSE endfinancialyear := DATEADD("s" , -1, (DATESERIAL (YEAR(dates)+1,4,1)));
Thus, returning a value of "31/03/xxxx 23:59:59"
(Currently set up for use in the UK)
No comments:
Post a Comment