--- type: "fhirpath-function" title: "FHIRPath Function: toDateTime" function: "toDateTime" category: "Conversion" section: "5.5.5.1" source: "fhirpath/functions.json" --- # FHIRPath Function: toDateTime _No canonical section match found in index.md._ ## Summary - **Category**: Conversion - **Section**: `5.5.5.1` - **Return Type**: `DateTime` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `true` ## Description If the input collection contains a single item, this function will return a single datetime if the item is a DateTime, a Date, or a String convertible to a DateTime. ## Arguments - `format` (optional): `String` - Optional format template for parsing string input (STU). Uses date/datetime format codes when provided instead of the default format. ## Type Mapping - `DateTime-DateTime` - `Date-DateTime` - `String-DateTime` ## Example ```fhirpath '2022-01-01T12:00:00Z'.toDateTime() // returns @2022-01-01T12:00:00Z ```