Getting a Date in An integer format

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
ravikiran2712
Participant
Posts: 38
Joined: Thu Nov 04, 2004 10:36 am

Getting a Date in An integer format

Post by ravikiran2712 »

Hi all,
i have to write a date in an integer format. can anyone please help me out.
Thanks,
Ravi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Define exactly what you mean by 'integer' format so that people don't spend time on the 'wrong' solution.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ravikiran2712
Participant
Posts: 38
Joined: Thu Nov 04, 2004 10:36 am

Post by ravikiran2712 »

Hi Craig,
I have to get the date in the integer(10) field. i think with OCONV we can have in string format.
Ravi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, was looking for a little more detail than that. Examples of input and output formats are always good. :wink:

If what you mean is that you need to strip formatting characters from the date, look at - in no particular order - the Trim and EReplace functions. The latter can be used to replace a character with 'nothing', in effect removing it from the target field.

More details will yield more targetted advice.
-craig

"You can never have too many knives" -- Logan Nine Fingers
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Try this !

Code: Select all




TRIM((OCONV(ICONV(DSLink.InDate,"DYMD[2,2,2]"), "DYMD[4,2,2]")), " ", "A")


Modify the format according to your requirements.

LET ME KNOW IF IT WORKED.

Thanks,

Naveen.
ravikiran2712
Participant
Posts: 38
Joined: Thu Nov 04, 2004 10:36 am

Post by ravikiran2712 »

Naveen,
It worked.
Thanks,
Ravi
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

What Craig was asking is to define what the integer format should look like. Should it be YYYYMMDD, or MMDDYYYY, padding with zeroes, what? Should it be the integer number of days since a given start date, what does integer(10) mean? That's not a common term for describing a date without delimiters.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly. Glad "it worked", however. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If the input date is already in YYYY-MM-DD then the solution given is non-optimal. All you need to do to get YYYYMMDD is to strip out the "-" characters. Some possible solutions are:
  • Trim(inLink.TheDate, "-", "A")

    Convert("-", "", inLink.TheDate)

    Oconv(inLink.TheDate, "MCN")

    inLink.TheDate[1,4] : inLink.TheDate[6,2] : inLink.TheDate[9,2]
I leave it as an exercise for the reader to determine which of these is the most efficient, and which will not necessarily yield the correct answer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply