Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
mahitham
Creator II
Creator II

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
Contributor III
Contributor III

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
Creator II
Creator II
Author

Hi Shwetha,

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

Which database? You want qlikview script or SQL?
mahitham
Creator II
Creator II
Author

SQL
shwethaa
Contributor III
Contributor III

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