Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
mahitham
Contributor

Quarter year and WeekYear extraction

Hi Experts,

Can any one please help me on below requirement.

I have a Sql table like below here p.todate in dd/mm/yyyy hh:mm:ss format.

from this p.todate field how to derive the Quarteryear and WeekYear fields in below format in Sql syntax only.

Please help me on this.

quarter and week.png

 

Sql Select

p.id

p.product,

p.todate

From products  p;

 

Thanks in advance

5 Replies
shwethaa
New Contributor III

Re: Quarter year and WeekYear extraction

Try Below script:

ql Select

p.id

p.product,

p.todate,
concat(Concat(Concat('Q',Quarter(p.todate)),'-'),year(p.todate)) as Quarter_year,
concat(concat(Datepart('ww',p.todate),'-'),year(p.todate)

From products p;

if datepart function doesn't work then please try this week() function.
mahitham
Contributor

Re: Quarter year and WeekYear extraction

Hi Shwetha,

Thanks for your reply.
I am getting error like Quarter and Year are the Invalid Identifier.
shwethaa
New Contributor III

Re: Quarter year and WeekYear extraction

Which database? You want qlikview script or SQL?
mahitham
Contributor

Re: Quarter year and WeekYear extraction

SQL
shwethaa
New Contributor III

Re: Quarter year and WeekYear extraction

if you are running in qlikview then you can extract table from sql database then do operations  on extracted table using qlikview script functions.