Skip to content

Evidence methods guide

BSON Datetime and Numeric Type Review: Keep Binary Types and Meaning Separate

Review BSON document boundaries, UTC datetime encoding, integer widths, floating point, Decimal128, and internal timestamp values before interpreting an export.

BSON stores several values that can look similar after a driver converts them to a language object. A UTC datetime is an int64 count of milliseconds since the Unix epoch in the BSON grammar, while an int64 integer, a double, a Decimal128 value, and a BSON timestamp are different element types. Start from the type byte and document boundary, retain the original representation, and record every conversion. This guide is a format worksheet, not a database query, timezone opinion, privacy decision, or permission claim.

Updated

On this page

Confirm the document boundary before reading fields

Record a neutral artifact ID, digest, byte offset, declared document length, observed end offset, and whether the final zero byte is present. The BSON Specification, (opens in a new tab) grammar puts a signed int32 length at the start and a zero terminator at the end. A parser that stops at a convenient object boundary can hide trailing bytes, truncation, concatenation, or an incorrect length.

The source dates in this guide use 22 October 2026 as retrieval evidence for documentation without a verified publication date. They are not publication claims. Where a verified publication date is available, it is recorded in the source ledger.

Confirm the document boundary before reading fields (table)
Boundary fieldRecordStop if
Byte orderLittle endian for typed scalar fieldsA tool reports host order only
Document lengthDeclared length and calculated endLength crosses the available bytes
TerminatorObserved zero byte at the declared endA parser accepts a missing terminator
Element sequenceType byte, cstring name, value spanA name contains an embedded zero
Trailing regionBytes after the documentTrailing bytes are silently dropped
Nested documentParent span and child spanChild length escapes the parent

Keep a raw byte-range report beside the driver object. The report can redact field names or values while preserving offsets and type bytes. Do not paste real identifiers, message text, or binary payloads into a public worksheet.

Do not collapse datetime and timestamp into one time field

The BSON Specification, (opens in a new tab) assigns type 9 to UTC datetime, represented as an int64 count of milliseconds since the Unix epoch. Type 17 is a BSON timestamp with two uint32 parts and is described as a special internal type for replication and sharding. Record the element type before a driver turns either value into a language date, integer, or formatted string.

Do not collapse datetime and timestamp into one time field (table)
Element typeFormat observationInterpretation boundary
UTC datetimeType 9 and int64 millisecond valueDo not infer a timezone label from display
BSON timestampType 17 with two uint32 partsDo not treat it as an event datetime
String dateType 2 UTF-8 textParse only with an explicit format policy
NullType 10 with no value bytesDo not convert null to an epoch
Int64Type 18 signed integerDo not assume milliseconds
Driver date objectConversion result and driver versionOriginal type is unavailable

Record the exact source value, conversion rule, displayed value, and timezone context as separate columns. A formatted UTC string may be useful for a reader, but it is a derivative. Preserve the raw integer and type byte so another reviewer can reproduce or challenge the conversion.

Compare numeric width, representation, and range

The BSON Specification, (opens in a new tab) defines int32 as a 32-bit signed integer, int64 as a 64-bit signed integer, double as an IEEE 754 binary floating point value, and Decimal128 as a 128-bit decimal floating point value. Those types can share a displayed number while carrying different precision, range, and rounding behavior. Record the BSON type and any driver conversion instead of comparing formatted text only.

Compare numeric width, representation, and range (table)
Review fieldRecordStop if
Type byteOriginal numeric typeThe driver type is the only evidence
WidthDeclared bit or decimal representationA narrow type is widened without policy
Exact textSource lexical or canonical representationFormatting rounds values before comparison
Special valueNull, NaN, infinity, or missing stateSpecial values become zero or blank
Array element typeType of each nested valueMixed types are silently coerced
ConversionDriver, language, and target typeThe conversion is undocumented

Synthetic type ledger

Compare numeric width, representation, and range code example, JSON
{"document":"fixture-bson-01","fields":[{"name":"when","bson_type":"utc_datetime","raw":"fixture-int64-millis","display":"fixture-UTC"},{"name":"count","bson_type":"int64","raw":"fixture-integer"},{"name":"ratio","bson_type":"double","raw":"fixture-binary-float"},{"name":"amount","bson_type":"decimal128","raw":"fixture-decimal"}],"conversion":"not assessed"}

Test driver round trips without replacing source evidence

Use a synthetic document to exercise decode, display, and re-encode paths. Capture the original type map, the language object type map, the serialized type map, and any changed values. A round trip that produces the same visible text can still change integer width, decimal representation, timestamp meaning, field order, or binary subtype.

Test driver round trips without replacing source evidence (table)
Round tripObserved resultQuestion to resolve
BSON to driver objectType map and display valuesDid date or numeric types change?
Driver object to BSONNew element types and raw valuesWas precision or null state lost?
Nested arrayKeys and element typesDid an array become a generic document?
Binary subtypeSubtype and byte lengthDid a UUID or sensitive subtype change?
Unknown extensionKept, rejected, or normalizedCan the source be reproduced?
Malformed documentError, repair, or partial parseWas the repair retained as evidence?

Stop when type evidence is missing

Stop conditions

  • Stop if the declared document length, nested span, byte order, or terminator is inconsistent.
  • Stop if a timestamp is interpreted as a datetime without a source type and conversion record.
  • Stop if an int32, int64, double, or Decimal128 value is compared only after lossy display formatting.
  • Stop if a driver maps null, missing, NaN, infinity, or binary subtypes to an unqualified default.
  • Stop if a malformed document was repaired and the original bytes or repair decision were not retained.
  • Stop before sampling real documents when field names or values expose private records or identifiers.

Pair this worksheet with the data provenance log for decoder and transformation history and the data card template for collection context. A type map does not prove data quality, ownership, privacy clearance, or permission.

For a supported non-health collection, after the owner has authority to describe the scope and a controlled metadata packet, the qualified appraisal request path may be a preparation step. It does not decode BSON, convert timezones, assess database behavior, create a quote, match a buyer, or grant a license.

Sources

  1. BSON Specification: BSON Specification Version 1.1 (opens in a new tab)
  2. MongoDB Documentation: BSON Types (opens in a new tab)

Use the appraisal path after the BSON type packet is organized.

It does not decode BSON, convert timezones, assess database behavior, create a quote, match a buyer, or grant a license.