Need to Calculate date & time in the format YYYYMMDD_HHM

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Suhel_2112
Premium Member
Premium Member
Posts: 10
Joined: Sun Jul 15, 2012 11:34 pm
Location: Bangalore

Need to Calculate date & time in the format YYYYMMDD_HHM

Post by Suhel_2112 »

Hi All,

In a sequence i am trying to calculate datetime in the format YYYYMMDD_HHMM and assign this to a variable and pass the variable to a job activity stage as a parameter.

The calculated value "YYYYMMDD_HHMM" will be appended as a suffix to an error file. So the error will have a name like Error_File_Table_YYYYMMDD_HHMM.txt

I tried using Oconv(date(),'YMD[422]'):'_':Oconv(time(),'MCN') to get this but all i get is number like this .. 17532231_7234.

or also, is there a way to calculate "YYYYMMDD_HHMM" inside the job itself and append the same to the error file..

Need help in this one ...
Thanks & Regards
Suhel Khan

Env Info:
DataStage Version : 8.5
DSEngine Platform : Windows Server 2008 R2
DWH Platform : Oracle 10g
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need commas in the format specification for the Oconv() function, and then you need to remove the default delimiters. That is, you probably should use something like

Code: Select all

Oconv(Date(), "DYMD[4,2,2]" : @VM : "MCN") : "_" : Oconv(Time(), "MT" : @VM : "MCN")
There's no convenient way to generate this within the job itself, but a commonly used approach is to write to a generic file name then use an after-job subroutine (ExecSH or ExecSHSilent) to rename that file, using the date command to generate the suffix.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Suhel_2112
Premium Member
Premium Member
Posts: 10
Joined: Sun Jul 15, 2012 11:34 pm
Location: Bangalore

Post by Suhel_2112 »

Ray, Thanks for the reply..

I did come up with a similar solution after some trial and error.

Code: Select all

Oconv(Oconv(Date(), "DYMD[4,2,2]"),"MCN")) : "_" : Oconv(Oconv(Time(), "MT"), "MCN"))
Thanks & Regards
Suhel Khan

Env Info:
DataStage Version : 8.5
DSEngine Platform : Windows Server 2008 R2
DWH Platform : Oracle 10g
Post Reply