Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to create quarter in mysql database

DEAR TEAM,

I HAVE A TABLE AS

SELECT MONTH,YEAR FROM FACT; in mysql database

But plz tell me the command by which i can devide the MONTH or Year Columns in 4 Quarter[Q1(jan-march),Q2(april-jun),Q3(july-sep),Q4(oct-dec)] .

Regards,

Rahul

2 Replies
hic
Former Employee
Former Employee

You can define a Quarter in the QlikView script using a preceding Load. (I assume that YEAR and MONTH are numeric.) Below you have two alternatives:

Load *,

          QuarterName(MakeDate(YEAR,MONTH)) as Quarter1,

  'Q' & ceil(MONTH/3) as Quarter2;

SQL SELECT MONTH,YEAR FROM FACT;

HIC

Not applicable
Author

You can use the below command to get a resulting Q1 through Q4 for your months.  All you would need to do is replace TempDate with your date field. You just need to add this line into your load script where the date field is being loaded.

'Q' & ceil(month(TempDate) /3) as Quarter

Hope this helps!