MONTH & YEAR FROM DATE

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ajithaselvan
Participant
Posts: 75
Joined: Mon Jul 12, 2010 4:11 am
Location: Chennai

MONTH & YEAR FROM DATE

Post by ajithaselvan »

Hi,
Pls let me know what is function to be used to get
only month & year from date. Format is below

Input: YYYY-MM-DD
Output: MM-YY



Thanks & Regards,
Ajitha S
dr.murthy
Participant
Posts: 224
Joined: Sun Dec 07, 2008 8:47 am
Location: delhi

Post by dr.murthy »

Use substring function
D.N .MURTHY
ajithaselvan
Participant
Posts: 75
Joined: Mon Jul 12, 2010 4:11 am
Location: Chennai

Post by ajithaselvan »

Thanks Murthy
Ajitha S
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This 'date' field, what actual data type are we talking about? The current answer is fine if you are talking about a string but it's not correct for an actual 'date date'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ajithaselvan
Participant
Posts: 75
Joined: Mon Jul 12, 2010 4:11 am
Location: Chennai

Post by ajithaselvan »

Hi chulett,
What would be the correct ans if the data type is date?





Thanks & Regards,
Ajitha S
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

you have to use "DateToString" function to define correct date mask.
Cheers
Ravi K
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Right("00":MonthFromDate(InLink.TheDate) : "-" : Right(YearFromDate(InLink.TheDate),2)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsa
Participant
Posts: 37
Joined: Sun Oct 10, 2010 7:52 am

Post by dsa »

ray.wurlod wrote:

Code: Select all

Right("00":MonthFromDate(InLink.TheDate) : "-" : Right(YearFromDate(InLink.TheDate),2)
...
Ray,

Should we use:

Right("00":MonthFromDate(InLink.TheDate),2) : "-" : Right(YearFromDate(InLink.TheDate),2)

??? as the requirement is MM-YY?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can you please advise what you think is wrong with the expression I gave?

Have you tried it?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Took me a minute but the difference is the "2" that was added at the end of this part for the month:

Code: Select all

Right("00":MonthFromDate(InLink.TheDate),2)
-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 »

:oops:

Code: Select all

Right("00":MonthFromDate(InLink.TheDate), 2) : "-" : Right(YearFromDate(InLink.TheDate), 2)
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