In a first blog post regarding conversions in SAP Gateway Foundation we discussed their relevance in the context of the differences between the ABAP type system and the OData type system. Although not directly related to conversions the handling of date and time perfectly fits into this topic.
ABAP knows date, time, and different representations of time stamps. And, it provides reuse functions to execute date and time calculations. OData has its own date and time definitions with functions that may be used in
$filter
expressions, for example.
Often, questions arise how the different representations map and how a data provider needs to be implemented to create a best match between both worlds. It is certainly not possible to dig into each and every detail. But, let us start with a few aspects.
Date and Time in OData
To represent date and time information, the OData specification in version 2.0 knows the three primitive types
Edm.DateTime,
Edm.Time, and
Edm.DateTimeOffset.
Since this is not really sufficient for business applications specification version 4.0 switches to
Edm.Date,
Edm.TimeOfDay,
Edm.DateTimeOffset, and
Edm.Duration.
We focus on specification version 2.0 and restrict the discussion to Edm.DateTime and Edm.DateTimeOffset. Details regarding the representations can be found in the
OData specification
, the
ISO 8601 standard
, and in
http://www.w3.org/TR/xmlschema-2
. Here, we quickly list the different formats. The literals are used in the URI, that is, in
$filter
expressions or key predicates, for example. ATOM and JSON refer to the content type of the request or response payload. The number of decimal places available for sub-seconds is defined by the facet precision.
Edm.DateTime represents a date and a time in
UTC
(formerly, Greenwich Mean Time):
Representation
Example
Literal
datetime'yyyy-mm-ddThh:mm[:ss[.fffffff]]'
datetime'2016-07-08T12:34:56'
ATOM
yyyy-mm-ddThh:mm[:ss[.fffffff]]
2016-07-08T12:34:56
JSON
"\/Date(<ticks>)\/"<ticks> = number of milliseconds since midnight Jan 1, 1970
"\/Date(1467981296000)\/"
The ticks in the JSON representation may also be negative to describe dates and time before Jan 1, 1970. "\/Date(-6847804800000)\/" is midnight Jan 1, 1753, for example.
Edm.DateTimeOffset adds time zone information relative to UTC. The date and time information is amended by the standard time difference (offset) with the sign
v
: +01:00 for Central European Time (CET) or -05:00 for Eastern Standard Time (EST), for example.
Quitar espacios en una consulta SQL
Quitar espacios en una consulta SQL
Cuando trabajamos con consultas SQL, a menudo nos encontramos con la necesidad de limpiar o mani...
Transacciones MIGO y MIRO en SAP MM
Transacciones MIGO y MIRO en SAP MM
1. ¿Qué es la transacción MIGO?
La transacción MIGO (Entrada de Mercancías) se utiliza para registrar las mercancías que...
HOLA EXPERTOS,
¿QUÉ ESQUEMA DE CÁLCULO ME SIRVE PARA CALCULAR EL IVA EN BOLIVIA?
EL PORCENTAJE DE IVA EN BOLIVIA ES EL 13%.
LA FACTURA QUE TENGO COMO EJEMPLO ES LA...
Pasos para abrir y cerrar período - MM FI CO
Muchos de nosotros luchamos con los cambios de períodos en nuestros entornos DEV y QA, aquí tienes una referencia rápida para abrir y...