Page 1 of 1

Problem with date function

Posted: Wed Aug 20, 2003 11:54 am
by jseclen
Hi,

I have a curious problem, my batch generate a log file using DSExecute to define it, when the first job run i get the date/time and write the file, when finish all jobs i write the date/time too.

The problem is when the batch start Monday at 23:00 pm and finish Tuesday at 05:00 AM, the first date/time was write in the log is Monday 23:00, and the finish date is Monday 05:00 ... is there a problem with the date function???



Miguel Seclen
Lima - Peru

Posted: Wed Aug 20, 2003 12:11 pm
by spracht
Not that I remember. Are you using the function Date() or the system variable @DATE? If it's the function, maybe you are not really updating your date, but re-using the value returned by the first call?

Stephan

Posted: Wed Aug 20, 2003 5:22 pm
by ray.wurlod
Show us how you are getting the date/time. In particular, what are you calling via DSExecute?

The @DATE, @DAY, @MONTH and @YEAR system variables are initialized when the job starts, and are not changed subsequently.

The Date() and Time() functions always return the date or time now.

NowAsTimeStamp = Oconv(Date(),"D-YMD[4,2,2]"):" ":Oconv(Time(), "MTS:")

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518

Posted: Wed Aug 20, 2003 8:21 pm
by kcbland
Actually, I think Ray's solution can potentially return an error if the logic is executed close enough to midnight. In the split second between the date function and the time function executing you rollover midnight. The more appropriate logic for a function should be using the TIMEDATE() statement, which insures that the time and date are associated:


now = TIMEDATE()
dt = OCONV(iconv(now[10,11],"D"),"D-YMD[4,2,2]")
tm = now[1,8]
Ans = dt:" ":tm




Kenneth Bland

Posted: Fri Aug 22, 2003 2:47 pm
by jseclen
Hi,

Thanx for your answers, the function used is

oConv(@DATE,'D/E').

Miguel Seclen
Lima - Peru