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

how to covert string to date
Hi Experts,
Please guide me on how to covert string to date.
I have string in this format 01-01-2020
I need this to be date format 01-01-2020
Reagrds
Karthic
Please guide me on how to covert string to date.
I have string in this format 01-01-2020
I need this to be date format 01-01-2020
Reagrds
Karthic
Sample Code:
String todate = '12/27/2013';
Date dt = Date.parse( todate );
system.debug(' Parsed Date is ' + dt );
For further reference, you can check the below blog too,
https://medium.com/@devendargona/how-to-convert-string-to-date-in-apex-9d273a1f61c8
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
Thanks for your reply.
but, I have sting in this format 01-01-2020.
Date dt = Date.parse( todate ); // this doesnt work with - format, can u pls help.
Regards
Karthic Sankar V P
Check the blog I have mentioned in the above.
15:23:53:014 USER_DEBUG [19]|DEBUG|Sankar2015-07-27 00:00:00
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000QzvbQAC