Symptom
The difference between datetime and datetimeoffset format in SF Odata API
"Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental."
Environment
SAP SuccessFactors HCM Suite
- Date and Time
Resolution
1. For DateTime format, the input value is in UTC time, and it is stored and retrieved from the database in the same format.
2. DateTimeOffset takes time zone into account when converting dates.
Let's consider an MDF entity as an example:
When the SF UI creates this entity with the Date Type set to 'Date', the field type is 'datetime', and it does not support adding a time zone at the moment.
However, when the SF UI creates this entity with the Date Type set to 'DateTime', the field type becomes 'datetimeoffset', and it allows for adding a time zone format.
POST: https://apisalesdemo8.successfactors.com/odata/v2/upsert?&$format=json
Payload:
{
"__metadata": {
"uri": " https://apisalesdemo8.successfactors.com:443/odata/v2/cust_ATMAA1('Test1')",
"type": "SFOData.cust_ATMAA1"
},
"externalCode": "Test1",
"cust_Date": "/Date(1662158098000)/",
"externalName": "test1",
"cust_DateTime": "/Date(1662158098000+0800)/"
}
Response:
{
"d": [
{
"key": "cust_ATMAA1/externalCode=Test1",
"status": "OK",
"editStatus": "UPSERTED",
"message": null,
"index": 0,
"httpCode": 200,
"inlineResults": null
}
]
}
Results:
1. The "Date" field only contains the date information.
2. The "DateTime" field includes both the date and time information, along with the corresponding timezone.
See Also
Keywords
datetime, datetimeoffset, different, timezone, non-timezone, MDF, Date Type , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT-MDF , Metadata Framework API (MDF) , Problem