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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Function Left doesn´t read correctly the date.

Im trying to extract the year and month, with functions left and mid, but when I extract the year from '2016-05-01', read 2014 instead of 2016.

debito.png

debito.png

1 Solution

Accepted Solutions
remi_roland
Partner - Contributor III
Partner - Contributor III

Hi,

It's absolutely normal.

Using $(vInicioPrincipalidad) you ask to qlikview an evaluation of the variable vInicioPrincipalidad so it will operate:

2016 - 1 - 1 = 2014 (read - as substraction operator)

You should force use your variable as a text string to do that use single quotes:

let year = left('$(vInicioPrincipalidad)',4);

or in this case you can use the function year to extract year from a date:

let year = year(vInicioPrincipalidad);

Hope it will help.

Regards.

View solution in original post

4 Replies
tamilarasu
Champion
Champion

Fernando,

Try this,

Let Year= Left('$(vInicioPrincipalidad)',4);

remi_roland
Partner - Contributor III
Partner - Contributor III

Hi,

It's absolutely normal.

Using $(vInicioPrincipalidad) you ask to qlikview an evaluation of the variable vInicioPrincipalidad so it will operate:

2016 - 1 - 1 = 2014 (read - as substraction operator)

You should force use your variable as a text string to do that use single quotes:

let year = left('$(vInicioPrincipalidad)',4);

or in this case you can use the function year to extract year from a date:

let year = year(vInicioPrincipalidad);

Hope it will help.

Regards.

antoniotiman
Master III
Master III

Try

Let Year = Left(vInicioPrincipalidad,4);

Not applicable
Author

Thanks Remi, it was really useful!