The Date Time format in a CAML query must comply with the ISO 8601 standard. This means that to update the time component of a Date/Time field in a SHarePoint list, the time and date must be formatted according to the ISO 8601 profile.
To ensure the time component of the dat/time filed is updated in SharePoint, use one of the the following date/time formats:
YYYY-MM-DDThh:mmTZD
(2009-07-27T21:20+01:00)
(2009-07-27T20:20Z)
or
YYYY-MM-DDThh:mm:ssTZD
(2009-07-27T21:20:30+01:00)
(2009-07-27T20:20:30Z)
Key Components:
- The date must be in YYYY-MM-DD format
- "T" indicates the start of the time
- the time must be in "hh:mm", or "hh:mm:ss" formats
- The time must be preceded by the time zone offset or a "Z" to indicate UTC (Coordinated Universal Time) the time zone offset must be in "+hh:mm" or "-hh:mm" formats
See W3C's Date and Time Formats for full details about the ISO8601 standard.
The following JScript function converts the date value from an InfoPath form field/control into an ISO 8601 date format for updating the time component of a date/time field in a SharePoint list using CAML:
//Convert the date value passed as a parameter
//into ISO 8601 standard.
//
//Pass NULL as the date parameter to return the
//current date and time in ISO 8601 format
//----------------------------------------
function getDateTime(date)
{
if (date != null)
{
//Date value supplied
d = date;
}
else
{
//No date supplied, Create new date object
d = new Date();
}
//Generate ISO 8601 date/time formatted string
var s = "";
s += d.getYear() + "-";
s += d.getMonth() + 1 + "-";
s += d.getDate();
s += "T" + d.getHours() + ":";
s += d.getMinutes() + ":";
//Replace the "Z" below with the required
//time zone offset (eg "+10:00" - Australian EST)
s += d.getSeconds() + "Z";
//Return the ISO8601 date string
return s;
}
Replace the "Z" with the required time zone offset, or leave if UTC is ok.
Related Articles:
- InfoPath - Update Repeating Elements/Nodes in a Secondary Data Source
- InfoPath - Update Existing SharePoint List Item Programmatically Using CAML
- Using Secondary InfoPath Data Connections to retrieve data from a SharePoint List or Library
- Integrate InfoPath Form with SharePoint Workflow
- Submit InfoPath form to SharePoint List or Library using Content Type
References:
No comments:
Post a Comment