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

how to get year from date

How to get year from date:

I am have the order_date colum in a table(like 07/20/1987), I need them to be in years. how can i get the years from dates? please help me with this.

Thank u.

6 Replies
er_mohit
Master II
Master II

Try this

Date(DateField,'YYYY') as Year         or this way

date(date#(DateField,'MM/DD/YYYY'),'YYYY') as Year or simply write

Year(DateField) as Year

hope it helps

Not applicable
Author

tried all nothing worked.

i am having the order date in orders table and quantity in order details table.

i joined the two by left join

Not applicable
Author

Order date formate is like this:

1996-07-05 00:00:00.000

1996-07-08 00:00:00.000

1996-07-08 00:00:00.000

1996-07-09 00:00:00.000

1996-07-10 00:00:00.000

how can i get the year out of this,please help

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

num#(left(MyDate,4)) as Year

or year(date#(MyDate, 'YYYY-MM-DD hh:mm:ss.fff')) as Year


talk is cheap, supply exceeds demand
er_mohit
Master II
Master II

Write this in script where is your order date field

year(Date#([Order Date],'YYYY-MM-DD hh:mm:ss.hhh')) as Year

MayilVahanan

Hi

Try like this

Load *,

year(Date#([Order Date],'YYYY-MM-DD hh:mm:ss.hhh')) as Year

From tableName;


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