+ Start a Discussion

AJAX Date Format

I am using the new sForce AJAX toolkit to create a new object.  I would like to default a date field on the object, but I keep getting an error when doing the set.  Can anyone tell me what the valid date format would be in this case?

Opp.set("CloseDate", doDateConversion());


function doDateConversion() {

var d = new Date();

var curr_date = d.getDate();

var curr_month = d.getMonth() + 1;

var curr_year = d.getFullYear();

var dateString = curr_year + "-" +   curr_month + "-" +   curr_date ;

return (dateString);



Hi Jesip,

If the field you are setting is of type Date or DateTime, then you pass the set method a Date type.  So, for Opp.set try Opp.set("CloseDate", new Date());