# SYSDATE and SYSTIME in Easytrieve

SYSDATE and SYSTIME are keywords in Easytrieve that will return Current System date and System time respectively.

``` LIST ON
JOB INPUT NULL
DISPLAY SYSDATE
DISPLAY SYSTIME
STOP
*```

Output will be

```07/02/12
04.40.47```

## 18 thoughts on “SYSDATE and SYSTIME in Easytrieve”

1. Prerna says:

I have a requirement in which i only have to process those records in the file, in which difference between System date and the date mentioned in each record < 3

My logic is getting complex since the file has records from 1990s also. Is there a function in Easytrieve which can make it easier or you can suggest a better way?

I only have to use Easytrieve

Thanks

2. Karthik says:

Hi Prerna,

There is no in-built function to calculate date difference.

But, I can suggest you one simple logic – since you are saying only 3 days difference allowed.
First get the current date from SYSDATE and write logic to calculate two previous day’s date.
From the input file, take each date and see if it matches with with any of the three dates. If yes, process. otherwise, skip.

also, SYSDATE gives only two digits of the Year.
use SYSDATE-LONG, which will give 4 digits of the year.

3. Prerna says:

I am sorry to have confused you( by not being clear with the question)
We actually need to calculate difference between the Years of the two date i.e System Date and the Year mentioned along the record

eg Difference in the 12/15/99 and Current System Date( I need to know differnce between Years i.e 2012 and 1999)

4. Karthik says:

ok, SYSDATE-LONG will give you the date like ’07/02/2012′, you can take last four digits and move it to a numeric variable. then, you can subtract the year you have in the file.

5. Sunil Patwal says:

How can we subtract 1 month from a date in eazytrieve. Or How can we subtract 30 days from a date, taking into consideration number of month days and leap year?.

6. Karthik says:

Hi Sunil,
there is no direct way to do that. You will need to manually handle all the scenarios to arrive at the date.

7. Sunil Patwal says:

Thanks Karthik for your response. While doing research on this topic I found that using DATECALC macro we can handle such scenario. But I am still researching how to use this Macro.

8. Supamanny says:

You can use CEECBLDY (IBM standard function) to translate the gregorian dates you want to compare into absolute dates where 1601 01 01 is 00001, and then just subtract the two resultant absolute dates from each other to work out the number of days between the two dates. You define the date fomats you send and receive.

9. HONEY says:

How to extract records from an inputfile in which the difference between two dates should be lie between one year?

10. Rituraj Singh Rawat says:

Karthik, change the spelling of SYSTIME in the article’s first line. 😛

11. Karthik says:

thanks Rituraj ! corrected..

i have a requirement like i have to print system date in the report title,i understand that the system date comes automatically in the report title but as i am using easytrieve plus my leading zero is being suppressed ie. 02/20/13 is being displayed as 2/20/13.my requirement is to have it displayed as 02/20/13..any suggestions..

13. John says:

There is no really easy way to do this, but you would have to place NODATE in your report line and actually parse out SYSDATE-LONG into a WS field and then depending on the month, add a 0 (zero) to the 1st position of the month.

14. Will says:

Old article, I know, but thanks for putting this together. I’m running a job now, displaying systime with every 5000th record, and the display always has the same time. In other words, it appears that SYSTIME is not updating dynamically. Is that normal? Is there a way to get it to update dynamically?

15. pankaj agarwal says:

Hi

how to display currentdate and time in report generation.please help me out as soon as possible,urgently required.

16. Abinash says:

How can i add 21 days to date – 07/23/2014
using easytrieve

17. Yzark Leon says:

I have a long running job and i want to display the time every on every 1000 records read to determine at which point in time every 1000 recs are processed.

I tried displaying the systime every 1k recs but the displayed all the same with the time the job starts even when my job runs for more than 5mins.

Is there a way to display it so i can know the elapsed time it spent while the job is running?

This site uses Akismet to reduce spam. Learn how your comment data is processed.