Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
manoranjan_d
Specialist
Specialist

Issue on retrieving the latest month

Hi all,

I m using the the below coding, but its not considering to take the value for the LATEST_MONTH FIELD

load

date(DATE,'YYYY') as YEAR,

  date(DATE,'MMM') as MONTH,

  if(date(DATE,'YYYY')=Year(Today()),date(DATE,'MM')) as LATEST_MONTH

FROM XXX table



1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Manioranjan,

Try,

Load

     Date(DATE,'YYYY') as YEAR,

     Date(DATE,'MMM') as MONTH,

     If(Year(DATE)=Year(Today()),date(DATE,'MM')) as LATEST_MONTH

FROM XXX table

View solution in original post

4 Replies
tamilarasu
Champion
Champion

Hi Manioranjan,

Try,

Load

     Date(DATE,'YYYY') as YEAR,

     Date(DATE,'MMM') as MONTH,

     If(Year(DATE)=Year(Today()),date(DATE,'MM')) as LATEST_MONTH

FROM XXX table

manoranjan_d
Specialist
Specialist
Author

thnaks got it but , now wht i need is example

if

2015 have from jan to dec

2016 have from jan to may

they need latest 14 months

so they need as

2016 from jan to may and also they need aug, sep, oct, nov, dec from 2015

so they need latest 14 months?

varshavig12
Specialist
Specialist

Addmonths() can help you for the last 14 months data

tamilarasu
Champion
Champion

Fine. try like below.

Load

     Date(DATE,'YYYY') as YEAR,

     Date(DATE,'MMM') as MONTH,

     If(DATE >= Monthstart(Addmonths(Today(),-14)),Date(DATE,'MM')) as LAST_14_MONTH,

FROM XXX table;