Problem with date function

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jseclen
Participant
Posts: 133
Joined: Wed Mar 05, 2003 4:19 pm
Location: Lima - Peru. Sudamerica
Contact:

Problem with date function

Post 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
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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
jseclen
Participant
Posts: 133
Joined: Wed Mar 05, 2003 4:19 pm
Location: Lima - Peru. Sudamerica
Contact:

Post by jseclen »

Hi,

Thanx for your answers, the function used is

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

Miguel Seclen
Lima - Peru
Post Reply