---
title: Build EDI-style date strings
summary: Parse EDI-format date/time strings into a `DateTime`, split a delimited date-range string, or render a date (or date range) back into EDI-style text.
status: draft
owner: Framework.NCore maintainers
last_reviewed: 2026-10-02
library: SAIF.NetCore.Common
reference_type: package
operation_id: OP-05
trigger: A consumer calls `DateMaker.MakeDateTime`, `.ExtractDateRange`, or `.EdiFileDateString`.
---

# Build EDI-style date strings

Parse EDI-format date/time strings into a `DateTime`, split a delimited date-range string, or render a date (or date range) back into EDI-style text. This operation is triggered when a consumer calls `DateMaker.MakeDateTime`, `.ExtractDateRange`, or `.EdiFileDateString`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-05 |
| **Trigger** | A consumer calls `DateMaker.MakeDateTime`, `.ExtractDateRange`, or `.EdiFileDateString`. |
| **Inputs** | `date` (string, `yyyyMMdd` or `yyMMdd`), optional `time` (string, default `"000000"`); or `value` (string, `-`-delimited); or `start`/`end` (`DateTime`/`DateTime?`) |
| **Outputs** | A `DateTime` (`MakeDateTime`), two `out DateTime` values (`ExtractDateRange`), or a formatted string (`EdiFileDateString`). |
| **Primary components** | `DateMaker.MakeDateTime`, `.ExtractDateRange`, `.EdiFileDateString` |
| **Entry point** | `src/SAIF.NetCore.Common/SAIF.NetCore.Common/SAIF.NetCore.Common/Helpers/DateMaker.cs` |

## Steps

1. For `MakeDateTime`: if `date` is 6 characters (`yyMMdd`), prefix it with `"20"`. ([BR-018](../business-rules.md#br-018-two-digit-edi-years-resolve-to-the-2000s-and-a-missing-time-means-midnight))
2. Right-pad `time` with `'0'` to 6 characters (`hhmmss`) when shorter than that. ([BR-018](../business-rules.md#br-018-two-digit-edi-years-resolve-to-the-2000s-and-a-missing-time-means-midnight))
3. Build and return the `DateTime` from the combined date and time strings.
4. For `ExtractDateRange`: split `value` on `-`, then convert `subDates[0]` and `subDates[1]` (the first two parts only) with `MakeDateTime`, assigning the results to the `out` parameters; any additional `-`-delimited parts beyond index 1 are read but silently ignored, not treated as an error.
5. For `EdiFileDateString`: format `start` as `yyyyMMdd`, and append `-` plus the `yyyyMMdd` formatting of `end` when `end` has a value.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Call DateMaker member]) --> Which{Which operation?}
	Which -->|MakeDateTime| YearCheck{date is 6 chars?}
	YearCheck -->|Yes| Prefix["Prefix with '20'"]
	YearCheck -->|No| PadTime
	Prefix --> PadTime[Right-pad time to hhmmss]
	PadTime --> BuildDT[Build DateTime]
	BuildDT --> End1([Return DateTime])
	Which -->|ExtractDateRange| SplitVal["Split value on '-'"]
	SplitVal --> ConvertParts["Convert first two parts<br>via MakeDateTime"]
	ConvertParts --> End2([Assign out begin/end])
	Which -->|EdiFileDateString| FormatStart[Format start as yyyyMMdd]
	FormatStart --> EndCheck{end has value?}
	EndCheck -->|Yes| AppendEnd["Append '-' plus<br>formatted end"]
	EndCheck -->|No| End3([Return formatted string])
	AppendEnd --> End3
```

## Failure and edge-case behavior

- A 2-digit (6-character `yyMMdd`) `date` input is always assumed to be in the 2000s; dates before 2000 or in 2100+ cannot be represented with that form. An 8-character `yyyyMMdd` input is unaffected by this restriction — the century prefix is only ever applied when `date.Length == 6`.
- `ExtractDateRange` reads only `subDates[0]` and `subDates[1]` after splitting on `-`; it silently ignores any extra `-`-delimited parts rather than throwing, and throws `IndexOutOfRangeException` only when the split produces fewer than 2 parts (no `-` present in `value` at all).*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- `src/SAIF.NetCore.Common/SAIF.NetCore.Common/SAIF.NetCore.Common/Helpers/DateMaker.cs`
