FASTBCP_DATEFORMAT
Overview
The FASTBCP_DATEFORMAT environment variable lets you specify a custom format string for converting date values to strings in the output. When not set, FastBCP uses the default yyyy-MM-dd HH:mm:sszzz.
The format string follows .NET standard and custom date/time format patterns.
Syntax
Windows
$env:FASTBCP_DATEFORMAT = "yyyyMMdd"
Linux/macOS
export FASTBCP_DATEFORMAT=yyyyMMdd
Configuration
| Property | Value |
|---|---|
| Type | Format string |
| Default | yyyy-MM-dd HH:mm:sszzz |
| Applies to | All output formats that serialize date columns as strings (CSV, JSON, etc.) |
| Since | FastBCP 1.0 |
Auto-adaptive formatting
The date format is auto-adaptive based on the column type:
- Date-only columns will always output as
yyyy-MM-ddregardless of the format string - Timestamp/DateTime columns will output as
yyyy-MM-dd HH:mm:sseven if a timezone token (zzz) is present in the format string - DateTimeOffset columns will include the timezone offset as specified
Format Examples
| Format string | Example output |
|---|---|
yyyy-MM-dd HH:mm:sszzz (default) | 2026-06-28 14:30:22+02:00 |
yyyy-MM-dd | 2026-06-28 |
yyyyMMdd | 20260628 |
dd/MM/yyyy | 28/06/2026 |
MM-dd-yyyy | 06-28-2026 |
yyyy/MM/dd | 2026/06/28 |
yyyy-MM-dd HH:mm:ss | 2026-06-28 14:30:22 |
Examples
Compact date format — no separators (PowerShell)
$env:FASTBCP_DATEFORMAT = "yyyyMMdd"
fastbcp -S myserver.database.windows.net `
-d MyDatabase `
-T dbo.MyTable `
--fileoutput "output.csv"
Output column value: 20260628
Compact date format — no separators (Linux/macOS)
export FASTBCP_DATEFORMAT=yyyyMMdd
fastbcp -S myserver.database.windows.net \
-d MyDatabase \
-T dbo.MyTable \
--fileoutput "output.csv"
Output column value: 20260628
Restore default ISO 8601 format
Windows
Remove-Item Env:FASTBCP_DATEFORMAT
Linux/macOS
unset FASTBCP_DATEFORMAT