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
Problem with date function
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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
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
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
now = TIMEDATE()
dt = OCONV(iconv(now[10,11],"D"),"D-YMD[4,2,2]")
tm = now[1,8]
Ans = dt:" ":tm
Kenneth Bland