Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
vanir88
Creator
Creator

How to extract Month from start date

Hi 

i have column as [start date ] , and i have to extract [month]  as a separate column and [quarter] as a separate column to use as filter, could you please help

In [start date] column records are like below format

  2023-01-01T08:50:59Z

 2023-01-23T09:49:51Z

 

i have to add this in script.

Labels (1)
2 Solutions

Accepted Solutions
vikasmahajan

hi,

you can try like this :

Month(floor([start date] )) as Month,

'Q' & alt(if(Month(floor([start date] ))<4,4),if(Month(floor([start date] ))<7,1),if(Month(floor([start date] ))<10,2),3) AS Quarter

in your script.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.

View solution in original post

MayilVahanan

Oh Quarter starts differently? You can alter based on ur requirement.

Load *, Month(Date) as Month, 'Q'&If(Match(Num(Month(Date)), 3,4,5), '3', If(Match(Num(Month(Date)), 6,7,8), '4', If(Match(Num(Month(Date)), 9, 10, 11), '1', '2'))) as Quarter;
LOAD *, Date(Date#(Left(SampleDate, 10), 'YYYY-MM-DD')) as Date INLINE [
SampleDate
2023-01-01T08:50:59Z
2023-01-23T09:49:51Z
];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
vikasmahajan

hi,

you can try like this :

Month(floor([start date] )) as Month,

'Q' & alt(if(Month(floor([start date] ))<4,4),if(Month(floor([start date] ))<7,1),if(Month(floor([start date] ))<10,2),3) AS Quarter

in your script.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
MayilVahanan

Hi

If your data is in string format, try like below

Load *, Month(Date) as Month, 'Q'&Ceil(Month(Date)/4) as Quarter;
LOAD *, Date(Date#(Left(SampleDate, 10), 'YYYY-MM-DD')) as Date INLINE [
SampleDate
2023-01-01T08:50:59Z
2023-01-23T09:49:51Z
];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
vanir88
Creator
Creator
Author

yes , this is working, but jan month taking it as Q4.

but we need  like below.

IF(3,4,5) then Q3

IF(6,7,8) then Q4

IF(9,10,11) then Q1

IF(12,1,2) then Q2

MayilVahanan

Oh Quarter starts differently? You can alter based on ur requirement.

Load *, Month(Date) as Month, 'Q'&If(Match(Num(Month(Date)), 3,4,5), '3', If(Match(Num(Month(Date)), 6,7,8), '4', If(Match(Num(Month(Date)), 9, 10, 11), '1', '2'))) as Quarter;
LOAD *, Date(Date#(Left(SampleDate, 10), 'YYYY-MM-DD')) as Date INLINE [
SampleDate
2023-01-01T08:50:59Z
2023-01-23T09:49:51Z
];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.