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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
RutiTaumanRubin
Creator
Creator

Extract year from date field - QlikSense

Hi,

I have date field in the following format: 6/29/2017 10:35 AM.

I want to extract the year from the field, i try the function year but it doesn't work.

Any Idea?

Thank you!

1 Solution

Accepted Solutions
sunny_talwar

Try this

Year(Date#(FieldName, 'M/D/YYYY hh:mm TT')) as Year

View solution in original post

10 Replies
sunny_talwar

Try this

Year(Date#(FieldName, 'M/D/YYYY hh:mm TT')) as Year

agigliotti
Partner - Champion
Partner - Champion

maybe this:

Year(Date#(FieldName, 'MM/DD/YYYY hh:mm TT')) as Year

RutiTaumanRubin
Creator
Creator
Author

Great ! it's work - Thank you!

RutiTaumanRubin
Creator
Creator
Author

Thank you

F1992
Contributor II
Contributor II

My date is in the below format :

2019-07-28 00:00:00.0000000       

and when I use your code the year shows as empty. Could you help me to solve the issue?

Taoufiq_Zarra

to extract the year you can use this verison :

Year(Date#('2019-07-28 00:00:00.0000000', 'YYYY-MM-DD hh:mm:ss.0000000')) as Year
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
F1992
Contributor II
Contributor II

Thank you, its works but what about if I have many dates  in my Excel sheet and I want to show in the filter  all years not only 2019.

Taoufiq_Zarra

you just have to change the hard date to the  your date field name

like

Year(Date#([Your_Date], 'YYYY-MM-DD hh:mm:ss.0000000')) as Year
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
F1992
Contributor II
Contributor II

I have more than 10000 date from 2000 to 2019 so there is way to show only year in the filttrt ?