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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date string - split year and month

Hi everyone,

I have retail data (product registered) where registrations are formatted as 'YYYY-MM' (one date string).

I also have additional sales data (product shipped) where the format is seperated - 'YYYY' for Year and 'MM' for months.

When loading fields into my qlikview file, how can I turn my retail data from one string, to seperate out the Year and Month?

Thanks,

Paul

4 Replies
v_iyyappan
Specialist
Specialist

Hi,

When load the date filed in QVW

using Date(Date#(Datefield,'YYYY-MM')) as DateField

then u can use

Year(DateField) As Year,

Month(DateField) As Month

or

Date(DateField,'YYYY') As Year,

Date(DateField,'MM') As Month

Regards,

mdmukramali
Specialist III
Specialist III

Dear ,

you can use

Year(FieldName) as Year and Month(FieldName) as Month

or else

Right(FieldName,4) as Year,

Left(FieldName,2) as Month

Thanks,

Mukram.

MayilVahanan

HI

Try like this

First Method:

Year(Date(DateField, 'YYYY-MM' )) as Year

Month(Date(DateField, 'YYYY-MM' )) as Month

Second Method:

Left(DateField,4) as Year,

Right(DateField,2) as Month

Third Method:

Subfield(DateField,'-',-1) as Month,

Subfield(DateField,'-',1) as Year


Regards,

R.Mayil Vahanan

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

If you need to make a date field then go with

Year(Date#(FieldName, 'YYYY-MM')) AS Year

Month(Date#(FieldName, 'YYYY-MM')) AS Month

If date field is not needed then you can use subfield

SubField(FieldName, '-', 1) As Year

SubField(FieldName, '-', 2) As Month