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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
hgromek
Contributor
Contributor

TalendDate.formatDate - Incorrect Year result

Hi! I use TalendDate.formatDate to pull the Year out of a Date however for all December dates in 2015 (i.e 2015-12-29) it is assigning a 2016 year? how is this happening, how can I fix it?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Actually forget that, the problem is your "YYYY". It should be "yyyy". Try that. This should explain it .....

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

View solution in original post

5 Replies
Anonymous
Not applicable

Can you show us your code?

hgromek
Contributor
Contributor
Author

TalendDate.formatDate("YYYY",row1.ship_date)

Anonymous
Not applicable

This *could* be a timezone calculation issue. Try using formatDateInUTC and see if that solves your issue. 

Anonymous
Not applicable

Actually forget that, the problem is your "YYYY". It should be "yyyy". Try that. This should explain it .....

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

cterenzi
Specialist
Specialist

For those not accustomed to reading Java documentation, "Y" in Java's SimpleDateFormat indicates "Week year" which extends the start of a year to include the entire week. Borrowing the example of 2015-12-29 (a Tuesday), this date evaluates to 2016 because 2016-01-01 (a Friday) is in the same week.

The results can vary depending on the calendar in use and the start day of the week (Monday vs. Sunday).

In short, use 'y' for years unless you have a very specific need.