You need to sign in to do that
Don't have an account?

datetime format returning wrong year
Hi,
I wrote this code back in 2014, it has been running fine until yesterday when a customer compained that the year was wrong:
String collectionDat = datetime.newInstance(Date.newInstance(2020, 12, 28), time.newInstance(0,0,0,0)).format('YYYY-MM-dd');
this should return '2020-12-28'
now it returns '2021-12-28'
any ideas?
I wrote this code back in 2014, it has been running fine until yesterday when a customer compained that the year was wrong:
String collectionDat = datetime.newInstance(Date.newInstance(2020, 12, 28), time.newInstance(0,0,0,0)).format('YYYY-MM-dd');
this should return '2020-12-28'
now it returns '2021-12-28'
any ideas?
The capital Y merge field is the WEEK YEAR i.e. 'YYYY' is the calendar year for the WEEK that the day falls in, which is determined by the calendar year for the SATURDAY of that week.
The lower case y merge field is the CALENDAR YEAR i.e. 'yyyy' is the calendar year as of that DAY.
Reference:
https://help.salesforce.com/articleView?id=000352245&language=en_US&mode=1&type=1
Hope this helps...
Thanks,
All Answers
The capital Y merge field is the WEEK YEAR i.e. 'YYYY' is the calendar year for the WEEK that the day falls in, which is determined by the calendar year for the SATURDAY of that week.
The lower case y merge field is the CALENDAR YEAR i.e. 'yyyy' is the calendar year as of that DAY.
Reference:
https://help.salesforce.com/articleView?id=000352245&language=en_US&mode=1&type=1
Hope this helps...
Thanks,
Thanks,