function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co 

Insert Date Values

How to insert valuse of Date datatype in Database ?

I used all the things 'YYYY-MM-DD' , 'DD-MM-YYYY' , DD-MM-YYYY

General error is :

Illegal conversion from String to Date or Integer to Date...

Please help me by query that How will I insert the values....

Best Answer chosen by Admin (Salesforce Developers) 
wkuehlerwkuehler

You can convert from string to datetime in the following manner:

 

String s = '2011-01-31 00:00:00';

DataTime dt = datetime.valueof(s);