Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

nikhilgarg
Contributor III

Error in expression

Hey,

In qliksense, i am trying to create a variable by calculate Year of posting date

My Date format is : MM/DD/YYYY hh:mm:ss TT

I am trying like:

vCurYear = Year(Date(Today(1), 'MM/DD/YYYY'))

Let say date is 10/25/2017, above expression giving me 2.02K in qliksense.

I want to store value i.e. 2017 in variable i.e. vCurYear.

How to solve this?

Thanks,

Nikhil Garg

1 Solution

Accepted Solutions
satheshreddy
Contributor III

Re: Error in expression

Hi Nikhil,

I have created Varaible As Date

am getting value in text box see.

Regards

Sathish

16 Replies
arulsettu
Honored Contributor III

Re: Error in expression

try this

vCurYear = max(Year(date))

nikhilgarg
Contributor III

Re: Error in expression

Nope, it is working in the same manner

arulsettu
Honored Contributor III

Re: Error in expression

can you share sample data

mikelmuru
New Contributor II

Re: Error in expression

try

vCurYear = Year(getdate())

satheshreddy
Contributor III

Re: Error in expression

Hi Nikil,

you have using the below EXP:

vCurYear = Year(Date(Today(1), 'MM/DD/YYYY'))

Please use like below

vCurYear = Year(Date(Today(), 'MM/DD/YYYY'))

Regards

Sathish

hf-group
Contributor III

Re: Error in expression

Try to change Number Formating:

Or you must change it to a String.

To Format it without the point.

nikhilgarg
Contributor III

Re: Error in expression

Hey Satti,

I tried your way but again same result. Pls find attached snapshot.

Also, i want to save the result in the variable.

nikhilgarg
Contributor III

Re: Error in expression

Hey Ralf,

I need to save the result in the variable. I tried same number format at variable level, but does not worked

nikhilgarg
Contributor III

Re: Error in expression

Hey Mikel,

Nope, it does not worked.