+ Start a Discussion

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) 

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


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

DataTime dt = datetime.valueof(s);