You need to sign in to do that
Don't have an account?
Sunil
How to store date itto Date field?
How to store date into Date field using scontrol? I am using follwing code to store date into custom field: -
tru.set("TB1__c","6/8/2007");
I am getting error "6/8/2007' is not a valid for the type 'xsd:date'.
Please advise, how can store date. This is really urgent.
Thanks.
Try this ...
http://wiki.apexdevnet.com/index.php/Create_a_many_to_many_relationship_with_a_multi-select_picklist
function toIsoDateTime(theDate) {
var today = new Date(theDate);
var year = today.getYear();
if (year < 2000) {
year = year + 1900;
}
var month = today.getMonth() + 1;
var day = today.getDate();
var hour = today.getHours();
var hourUTC = today.getUTCHours();
var diff = hour - hourUTC;
var hourdifference = Math.abs(diff);
var minute = today.getMinutes();
var minuteUTC = today.getUTCMinutes();
var minutedifference;
var second = today.getSeconds();
var timezone;
if (minute != minuteUTC && minuteUTC < 30 && diff < 0) { hourdifference--; }
if (minute != minuteUTC && minuteUTC > 30 && diff > 0) { hourdifference--; }
if (minute != minuteUTC) {
minutedifference = ":30";
} else {
minutedifference = ":00";
}
if (hourdifference < 10) {
timezone = "0" + hourdifference + minutedifference;
} else {
timezone = "" + hourdifference + minutedifference;
}
if (diff < 0) {
timezone = "-" + timezone;
} else {
timezone = "+" + timezone;
}
if (month <= 9) month = "0" + month;
if (day <= 9) day = "0" + day;
if (hour <= 9) hour = "0" + hour;
if (minute <= 9) minute = "0" + minute;
if (second <= 9) second = "0" + second;
return year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":" + second + timezone;
}
If all you want to do is change the date a user enters in a web form to a date the api likes you can use this silly little function I wrote.
Pass in the date value and the type which is 'api' or 'user', type 'api' returns the api version of the date.
This is not pretty or elegant in any way but it gets the job done. Keep in mind it only works for US formated dates.
Code:
you can also try this :
tru.set("TB1__c", new Date("6/8/2007") );
I use this syntax to store the dates. This is valid for only US format dates. if you need to store the UK format dates, then you have to write a little function which will convert the UK format date string into a US format date string and then this line of code will work.
Let me know if you need more help.
Regards
Mojeeb