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

Divide by month / Year

Hi everyone,

I have to load some data and group by month and year. The field "SIMPLEDATE" is composed of Year-Month-Day (2015-11-30).
I need to divide this field and create two new field, YEAR and MONTH, so I can group by with this two new fields.

I have this script:

LOAD

  SIMPLEDATE

  count(*) as rich_totali

  

  

FROM  [log.qvd]

(qvd)

group by

SIMPLEDATE
store * from log into [ogSintesi.qvd] (qvd);

_____________________________________________________________

I need something like this

LOAD

     Year([SIMPLEDATE]) as YEAR,

     Month([SIMPLEDATE]) as MONTH,

count(*) as rich_totali

  

  

FROM  [log.qvd]

(qvd)

group by

YEAR,

MONTH,
store * from log into [ogSintesi.qvd] (qvd);

1 Reply
oknotsen
Master III
Master III

Is that SIMPLEDATE stored as text or actually stored as a date but shown in this weird format?

If it is text, you could use these:

left(SIMPLEDATE, 4) as YEAR,

mid(SIMPLEDATE, 6, 2) as Month

May you live in interesting times!