bson | timestamp functions
This section describes functions for working with BSON timestamp values.
BSON (Binary JSON) is a binary representation of JSON-like documents used primarily by MongoDB. Some systems that implement MongoDB-compatible APIs, such as Azure Cosmos DB, also support BSON documents.
A BSON timestamp is a 64-bit value that consists of two 32-bit parts:
•time_t value (most significant 32 bits): the number of seconds since the Unix epoch (1970-01-01T00:00:00Z)
•ordinal value (least significant 32 bits): an incrementing counter used to distinguish operations occurring within the same second
Note: BSON timestamps use a 32-bit value to store seconds since the Unix epoch. This limits the maximum representable date to the year 2038.
MapForce supports the following BSON timestamp functions:
•timestamp-datetime: Returns the datetime value in UTC, converted from the stored number of seconds since the Unix epoch.
•timestamp-ordinal: Extracts the timestamp’s ordinal value.
•to-timestamp: Creates a timestamp from a datetime and an ordinal.
Note: BSON Timestamps are primarily intended for internal use in MongoDB. For general date and time values, use the BSON Date type.
How dates are handled in MapForce
BSON Date values (milliseconds since the Unix epoch) are automatically converted to and from datetime values. For details, see the table below.
Conversion | What happens |
|---|---|
bson.date > string | Produces an ISO 8601 datetime string (e.g., 2020-02-02T01:02:02Z).
Note: BSON dates are stored in UTC. |
string > bson.date | Parses an ISO datetime string, converts it to UTC, and stores it as a BSON Date. |
Useful links