Salesforce Asked on January 2, 2022
PROBLEM:
I converted a string to Date format.
Eg: String dateToParse = year+’-‘+month1+’-‘+day;
Date ds = Date.parse(dateToParse);
OUTPUT: 2020-07-24 00:00:00 (output is a Date type variable)
Expected: OUTPUT: 2020-07-24 (without the time 00:00:00, still maintaining the Date type variable)
Note: I know that using ds.format() would give me the expected output, but this converts it into a string. I want to maintain the date type format.
Date types are intrinsically DateTime types with the time factor set to 00:00:00. You can't have a Date that does not have a time factor. What you're asking for is impossible.
Answered by sfdcfox on January 2, 2022
4 Asked on February 10, 2021 by imajmdf
1 Asked on February 8, 2021 by cloudy-ritz
0 Asked on February 7, 2021 by hemant-kumar-reddy
1 Asked on February 7, 2021 by mehsf
2 Asked on February 6, 2021 by jitesh-goel
1 Asked on February 6, 2021 by aakash-poudel
2 Asked on February 5, 2021 by divad
0 Asked on February 4, 2021 by sk_112
apex controller javascript lightning lightning aura components
1 Asked on February 3, 2021 by user-2147482428
0 Asked on February 3, 2021 by danielle-b
1 Asked on February 2, 2021 by victorcorey
1 Asked on January 30, 2021 by martijn-e
1 Asked on January 30, 2021 by 4kaudio
0 Asked on January 30, 2021 by devops85
0 Asked on January 29, 2021
3 Asked on January 29, 2021 by user75427
1 Asked on January 29, 2021 by dilip-irabatti
2 Asked on January 29, 2021 by ryan-mcneely
Get help from others!
Recent Questions
Recent Answers
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP