Solved

is "YYYY" the same as "yyyy"

  • 14 December 2021
  • 3 replies
  • 170 views

Userlevel 4
Badge +4

Hello , 

we have experienced strange behaviour of the system. Dates in the last week of the year were changed/forwarded on layouts by one year. When date in the system was 31.12.2020 it was printed as 31.12.2021. WQe have discovered that in used languages Short date format was set to “YYYY-MM-dd” when changed to “yyyy-MM-dd” dates are printed correctly. 

Can someone please provide explanation ? What is difference between YYYY-MM-dd and yyyy-MM-dd ? 

Thanks Martin 

icon

Best answer by Anjaleen Davidson 15 December 2021, 10:16

View original

This topic has been closed for comments

3 replies

Userlevel 3
Badge +5

Hi Martin,

 

YYYY returns the “year of the week”. Whereas yyyy just returns the specific “year of the date”.


In your example 31/12/2020,
“yyyy” denotes the year of the date, which is “2020”.
YYYY” denotes the year of the week. 31st of December 2020 is a Thursday but it falls in the 1st week of year 2021 as you can see below. Therefore YYYY returns 2021, which result in 31/12/2021.

 

 

Better to use date format ”yyyy-MM-dd” since it is logically correct for your purpose. Hope this is what you have asked.

 

Best Regards,

Anjaleen

Userlevel 4
Badge +4

Yes, Yes, Yes. That’s exactly what wanted to hear/read. I am so glad we have found what is behond the our issue. Thank You . You’ve made my day. Regards. Martin 

Userlevel 6
Badge +14

@llemartinhae,

I think there is something else wrong in your system. 2020 had 53 weeks:

 

Therefore yyyy and YYYY should return 2020.