CMD Simulator
System Informationdate

DATE Command: Display and Set System Date in Windows CMD | Guide

Master the DATE command to view and modify Windows system date. Complete guide with examples, batch scripting tips, and date manipulation techniques.

Rojan Acharya··Updated Feb 13, 2026
Share

The DATE command is a Windows Command Prompt utility that displays the current system date and optionally allows you to change it. Run DATE /T to view the current date without prompting for changes, or run DATE alone to both display and interactively set a new date. This command provides quick date access for scripts, logs, and system administration tasks.

Whether you're a system administrator managing server time synchronization, a developer creating timestamped logs, or an IT professional troubleshooting date-related issues, the DATE command provides instant access to system date information and modification capabilities. Batch script developers rely on DATE for generating date-based filenames, log timestamps, and date-dependent conditional logic.

This comprehensive guide covers DATE command syntax, all parameters and options, practical examples for viewing and setting dates, real-world use cases for IT professionals and developers, troubleshooting tips for date-related issues, and frequently asked questions. By the end, you'll efficiently manage system dates and incorporate date logic into your automation workflows.

What Is the DATE Command?

The DATE command is a built-in Windows command-line utility available in all Windows versions from MS-DOS through Windows 11. It displays the current system date in the format configured in Windows Regional Settings (typically MM/DD/YYYY in the US) and can interactively prompt to change the date or display it non-interactively with the /T parameter.

DATE runs in Command Prompt (CMD) and batch files with identical behavior. The command requires standard user permissions to view the date but needs administrator privileges to change it. The output format varies based on your Windows Regional Settings—US systems show MM/DD/YYYY, European systems show DD/MM/YYYY, and ISO format shows YYYY-MM-DD. This locale-awareness makes DATE useful for international deployments but requires careful parsing in scripts.

Syntax

DATE [/T | date]

Parameters

ParameterDescriptionRequired
/TDisplays the current date without prompting to change itNo
dateSets the system date to the specified value (format: MM-DD-YYYY)No
(none)Displays current date and prompts for a new dateNo

Parameters and Options

DATE (No Parameters)

Running DATE without parameters displays the current system date and prompts you to enter a new date. Press Enter without typing anything to keep the current date unchanged. This interactive mode is useful for manual date adjustments but not suitable for batch scripts where user interaction isn't possible.

The prompt format is "Enter the new date: (MM-DD-YY)" though the exact format depends on your Regional Settings. The command accepts various date formats including MM-DD-YY, MM-DD-YYYY, MM/DD/YY, and MM/DD/YYYY. Invalid dates (like 13/45/2026) are rejected with an error message.

/T (Display Only)

The /T parameter displays the current date without prompting for changes. This non-interactive mode is essential for batch scripts, log files, and automated processes where user input isn't available or desired. The output is a single line showing the current date in your system's configured format.

Example: DATE /T outputs "Thu 02/13/2026" (format varies by locale). Use this in scripts to capture the current date for timestamping, logging, or date-based logic without triggering interactive prompts.

Setting Date Directly

You can set the system date directly by providing a date value: DATE MM-DD-YYYY. This requires administrator privileges and immediately changes the system date without prompting for confirmation. Use this for automated date changes in deployment scripts or testing scenarios.

Example: DATE 12-25-2026 sets the system date to December 25, 2026. This bypasses the interactive prompt but requires elevated permissions. Invalid dates are rejected, and the command returns an error code.

Examples

Example 1: Display Current Date Without Prompt

Scenario: You need to see the current date quickly without interactive prompts.

DATE /T

Expected Output:

Thu 02/13/2026

Explanation: Displays the current date with day-of-week abbreviation in your system's date format. The /T parameter prevents the interactive prompt, making this suitable for quick checks and batch scripts.

Example 2: Display Date and Prompt for Change

Scenario: You want to see the current date and optionally change it.

DATE

Expected Output:

The current date is: Thu 02/13/2026
Enter the new date: (mm-dd-yy)

Explanation: Shows current date and waits for input. Press Enter to keep the current date, or type a new date to change it. Requires administrator privileges to actually change the date.

Example 3: Create Timestamped Log File

Scenario: Your batch script needs to create a log file with today's date in the filename.

@ECHO OFF
FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO SET TODAY=%%c-%%a-%%b
ECHO Creating log file: log_%TODAY%.txt
ECHO Script started at %TIME% > log_%TODAY%.txt

Expected Output:

Creating log file: log_2026-02-13.txt

Explanation: Parses DATE /T output to extract date components and creates a filename like log_2026-02-13.txt. This enables date-based log rotation and organization.

Example 4: Set System Date (Requires Administrator)

Scenario: You need to set the system date to a specific value for testing.

DATE 03-15-2026

Expected Output:

(No output if successful; error message if insufficient privileges)

Explanation: Sets the system date to March 15, 2026. Requires running CMD as administrator. Use this for testing date-dependent applications or correcting incorrect system dates.

Example 5: Display Date in Batch Script Header

Scenario: Your batch script needs to log when it was executed.

@ECHO OFF
ECHO ========================================
ECHO Script Execution Report
ECHO ========================================
ECHO Date: %DATE%
ECHO Time: %TIME%
ECHO User: %USERNAME%
ECHO Computer: %COMPUTERNAME%
ECHO ========================================

Expected Output:

========================================
Script Execution Report
========================================
Date: Thu 02/13/2026
Time: 14:30:25.45
User: JohnDoe
Computer: DESKTOP-ABC123
========================================

Explanation: Uses the %DATE% environment variable (equivalent to DATE /T) to display execution date in script logs. This provides audit trails and troubleshooting context.

Example 6: Parse Date Components for Logic

Scenario: Your script needs to extract month, day, and year for date-based logic.

@ECHO OFF
FOR /F "tokens=1-3 delims=/ " %%a IN ('DATE /T') DO (
    SET DOW=%%a
    SET MONTH=%%b
    SET DAY=%%c
    SET YEAR=%%d
)
ECHO Day of Week: %DOW%
ECHO Month: %MONTH%
ECHO Day: %DAY%
ECHO Year: %YEAR%

Expected Output:

Day of Week: Thu
Month: 02
Day: 13
Year: 2026

Explanation: Parses DATE /T output into separate variables for day-of-week, month, day, and year. Use these components for conditional logic, calculations, or custom date formatting.

Example 7: Create Date-Based Backup Directory

Scenario: Your backup script needs to create a directory named with today's date.

@ECHO OFF
FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO SET BACKUP_DATE=%%c%%a%%b
SET BACKUP_DIR=C:\Backups\backup_%BACKUP_DATE%
MKDIR "%BACKUP_DIR%"
ECHO Created backup directory: %BACKUP_DIR%

Expected Output:

Created backup directory: C:\Backups\backup_20260213

Explanation: Creates a backup directory with date in YYYYMMDD format for chronological sorting. This enables organized, date-based backup retention and easy identification of backup age.

Example 8: Check if Today is a Specific Day

Scenario: Your script should only run on Mondays.

@ECHO OFF
DATE /T | FINDSTR /C:"Mon" >NUL
IF %ERRORLEVEL% EQU 0 (
    ECHO Today is Monday - running weekly tasks
    REM Weekly maintenance tasks here
) ELSE (
    ECHO Today is not Monday - skipping weekly tasks
)

Expected Output:

Today is not Monday - skipping weekly tasks

Explanation: Checks if DATE /T output contains "Mon" to determine if today is Monday. Use this pattern for day-of-week dependent tasks like weekly backups or maintenance.

Example 9: Compare Dates for File Retention

Scenario: Your script needs to determine if files are older than 30 days for cleanup.

@ECHO OFF
REM Get current date components
FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO (
    SET /A CURRENT_MONTH=%%a
    SET /A CURRENT_DAY=%%b
    SET /A CURRENT_YEAR=%%c
)

REM Calculate days since epoch (simplified)
SET /A CURRENT_DAYS=(%CURRENT_YEAR%*365)+(%CURRENT_MONTH%*30)+%CURRENT_DAY%

ECHO Current date value: %CURRENT_DAYS%
REM Compare with file dates for retention logic

Expected Output:

Current date value: 739243

Explanation: Converts current date to a numeric value for comparison with file dates. While simplified, this demonstrates date arithmetic for file retention and cleanup scripts.

Example 10: Display Multiple Date Formats

Scenario: You need to display the date in multiple formats for different purposes.

@ECHO OFF
REM Standard format
ECHO Standard format: %DATE%

REM ISO format (YYYY-MM-DD)
FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO (
    ECHO ISO format: %%c-%%a-%%b
)

REM Compact format (YYYYMMDD)
FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO (
    ECHO Compact format: %%c%%a%%b
)

REM Long format
FOR /F "tokens=1-4 delims=/ " %%a IN ('DATE /T') DO (
    ECHO Long format: %%a, %%b/%%c/%%d
)

Expected Output:

Standard format: Thu 02/13/2026
ISO format: 2026-02-13
Compact format: 20260213
Long format: Thu, 02/13/2026

Explanation: Demonstrates parsing and reformatting DATE output for different use cases: ISO format for databases, compact format for filenames, long format for reports.

Common Use Cases

1. Timestamped Log File Creation

Batch scripts use DATE to create log files with date-stamped names (e.g., log_2026-02-13.txt), enabling automatic log rotation, chronological organization, and easy identification of log age for troubleshooting and compliance.

2. Date-Based Backup Directory Organization

Backup scripts use DATE to create dated backup directories (e.g., backup_20260213), organizing backups chronologically and making it easy to identify backup age for retention policy enforcement and disaster recovery.

3. Audit Trail and Compliance Logging

System administration scripts use DATE to timestamp all actions in audit logs, creating compliance records that document when changes were made, who made them, and what systems were affected.

4. Scheduled Task Day-of-Week Validation

Maintenance scripts use DATE to verify the current day of week, ensuring weekly tasks only run on designated days (e.g., Monday backups, Friday reports) without relying on Task Scheduler.

5. File Retention and Cleanup Automation

Cleanup scripts use DATE to calculate file age and delete files older than retention periods (e.g., 30 days, 90 days), automating storage management and compliance with data retention policies.

6. System Date Verification Before Critical Operations

Installation and deployment scripts use DATE to verify system date is reasonable before proceeding, preventing issues caused by incorrect system clocks (certificate validation, license checks, time-based encryption).

7. Date-Dependent Conditional Logic

Scripts use DATE to implement date-based business logic: end-of-month processing, quarterly reports, annual maintenance, or date-range specific operations that should only run during certain periods.

8. Report Generation with Date Headers

Automated reporting scripts use DATE to add date headers to reports, clearly identifying report generation time for distribution, archiving, and version tracking.

9. Testing Date-Dependent Applications

Quality assurance teams use DATE to set system dates to specific values for testing date-dependent features: license expiration, trial periods, subscription renewals, and date-based calculations.

10. Cross-System Date Synchronization Verification

System administrators use DATE to verify date consistency across multiple systems, identifying systems with incorrect dates that could cause authentication failures, certificate errors, or data synchronization issues.

11. Temporary File Management

Scripts use DATE to create temporary files with unique date-based names, preventing filename conflicts when multiple instances run simultaneously and enabling automatic cleanup of old temporary files.

12. Change Management Documentation

Change management scripts use DATE to timestamp configuration changes, creating before/after snapshots with dates for rollback planning, change verification, and compliance documentation.

Tips and Best Practices

1. Always Use /T in Batch Scripts

Use DATE /T instead of DATE in batch scripts to prevent interactive prompts that would cause scripts to hang waiting for user input. The /T parameter ensures non-interactive operation.

2. Use %DATE% Environment Variable for Speed

The %DATE% environment variable contains the same value as DATE /T and is faster because it doesn't spawn a new process. Use %DATE% in simple scripts; use DATE /T when you need to parse output.

3. Account for Regional Date Format Differences

DATE output format varies by Regional Settings (MM/DD/YYYY vs. DD/MM/YYYY vs. YYYY-MM-DD). Test scripts on systems with different locales or use PowerShell's Get-Date for consistent formatting.

4. Require Administrator Privileges for Date Changes

Changing system date requires administrator privileges. Always run CMD as administrator when scripts need to modify the date, and include error handling for access denied errors.

5. Use PowerShell for Complex Date Operations

For date arithmetic, comparisons, and formatting, use PowerShell's Get-Date cmdlet which provides rich date objects with built-in methods. DATE is best for simple display and basic parsing.

6. Validate Date Input in Interactive Scripts

When accepting date input from users, validate the format and range before passing to DATE. Invalid dates cause errors and may leave the system date unchanged or in an unexpected state.

7. Document Date Format Assumptions

When parsing DATE output, document the expected format in script comments. This helps troubleshoot issues when scripts run on systems with different Regional Settings.

8. Use ISO Format (YYYY-MM-DD) for Filenames

Convert DATE output to ISO format (YYYY-MM-DD) for filenames and logs. This format sorts chronologically and is internationally recognized, avoiding ambiguity between MM/DD and DD/MM formats.

9. Combine DATE with TIME for Complete Timestamps

Use both %DATE% and %TIME% for complete timestamps: ECHO %DATE% %TIME% - Action completed. This provides precise timing for troubleshooting and audit trails.

10. Test Date Parsing on Multiple Windows Versions

DATE output format can vary slightly between Windows versions and locale settings. Test date parsing logic on all target Windows versions to ensure compatibility.

11. Use WMIC for Locale-Independent Date

For scripts that must work across all locales, use WMIC OS GET LocalDateTime which returns date in YYYYMMDDHHMMSS format regardless of Regional Settings.

12. Restore Original Date After Testing

When changing system date for testing, always restore the original date afterward. Consider using NET TIME \\domain-controller /SET /YES to resync with domain time after testing.

Troubleshooting Common Issues

Issue 1: "A required privilege is not held by the client" When Setting Date

Problem: Running DATE 12-25-2026 returns "A required privilege is not held by the client" error.

Cause: Changing system date requires administrator privileges. Running DATE in a standard (non-elevated) Command Prompt cannot modify the date.

Solution: Right-click Command Prompt and select "Run as administrator" before executing DATE commands that change the date. Viewing the date with DATE /T doesn't require elevation.

Prevention: Always run CMD as administrator when scripts need to modify system date. Include privilege checks in scripts: NET SESSION >NUL 2>&1 returns error if not elevated.


Issue 2: Date Format Differs on Different Systems

Problem: Batch script date parsing works on your system but fails on other systems with different Regional Settings.

Cause: DATE output format depends on Windows Regional Settings. US systems show MM/DD/YYYY, European systems show DD/MM/YYYY, and some show YYYY-MM-DD.

Solution: Use locale-independent date retrieval: WMIC OS GET LocalDateTime returns YYYYMMDDHHMMSS format regardless of locale. Or use PowerShell: Get-Date -Format "yyyy-MM-dd".

Prevention: Test scripts on systems with different Regional Settings. Document date format assumptions and consider using WMIC or PowerShell for consistent date formatting.


Issue 3: DATE Command Hangs in Batch Script

Problem: Batch script stops executing when it reaches the DATE command and appears to hang.

Cause: Using DATE without /T parameter triggers an interactive prompt waiting for user input, which never comes in automated scripts.

Solution: Always use DATE /T in batch scripts to prevent interactive prompts. Replace all instances of DATE with DATE /T in automated scripts.

Prevention: Use DATE /T or %DATE% environment variable in scripts. Reserve DATE without parameters for interactive command-line use only.


Issue 4: Cannot Parse Date Components Correctly

Problem: FOR /F parsing of DATE output extracts wrong values or fails completely.

Cause: Incorrect token numbers or delimiters that don't match your system's date format. Different locales use different separators (/ vs. - vs. .) and component orders.

Solution: Adjust token numbers and delimiters for your locale: FOR /F "tokens=1-4 delims=/ " %%a IN ('DATE /T') for US format. Test with ECHO statements to verify extracted values.

Prevention: Use WMIC for locale-independent parsing: WMIC OS GET LocalDateTime returns consistent format. Or use PowerShell for robust date handling.


Issue 5: Date Change Doesn't Persist After Reboot

Problem: Manually set date reverts to incorrect value after system reboot.

Cause: System is configured to sync time with a time server (domain controller, NTP server) that has incorrect time, or CMOS battery is failing and BIOS time is wrong.

Solution: For domain computers, verify domain controller time is correct. For workgroup computers, check Windows Time service configuration: w32tm /query /status. Replace CMOS battery if BIOS time resets.

Prevention: Configure proper time synchronization with reliable time sources. For domain computers, ensure domain controllers sync with external NTP servers. Monitor time drift with automated scripts.


Issue 6: Invalid Date Error When Setting Date

Problem: Running DATE 13-45-2026 or other invalid dates returns "The system cannot accept the date entered."

Cause: The date value is invalid (month > 12, day > 31 for the month, or year out of range). DATE validates input and rejects impossible dates.

Solution: Verify date values are valid: months 1-12, days 1-31 (accounting for month length), years 1980-2099. Use correct format for your locale (MM-DD-YYYY for US).

Prevention: Validate date values in scripts before passing to DATE. Use date calculation functions or PowerShell's Get-Date for date arithmetic to avoid invalid dates.

Frequently Asked Questions

What is the difference between DATE and %DATE%?

DATE /T is a command that executes and returns the current date, while %DATE% is an environment variable that contains the date value. %DATE% is faster because it doesn't spawn a process, but DATE /T output can be parsed more reliably in FOR loops.

How do I change the date format displayed by DATE?

DATE format is controlled by Windows Regional Settings (Control Panel → Region → Formats). Change the "Short date" format to modify DATE output. Alternatively, use PowerShell's Get-Date -Format "yyyy-MM-dd" for custom formatting without changing system settings.

Can I use DATE to get yesterday's or tomorrow's date?

No, DATE only shows the current system date. For date arithmetic (yesterday, tomorrow, date ranges), use PowerShell: (Get-Date).AddDays(-1) for yesterday, (Get-Date).AddDays(1) for tomorrow.

Why does DATE show a different format than my Windows Settings?

DATE uses the "Short date" format from Regional Settings, not the "Long date" format. Check Control Panel → Region → Formats → Short date to see the format DATE uses.

How do I set the date in a batch script without user interaction?

Use DATE MM-DD-YYYY format: DATE 12-25-2026 sets the date directly without prompting. This requires administrator privileges. For automated scripts, run CMD as administrator.

Can DATE set the time as well as the date?

No, DATE only sets the date. Use the TIME command to set the time: TIME HH:MM:SS. To set both, run both commands: DATE 12-25-2026 & TIME 14:30:00.

How do I get the date in YYYYMMDD format for filenames?

Parse DATE /T output: FOR /F "tokens=2-4 delims=/ " %%a IN ('DATE /T') DO SET DATESTR=%%c%%a%%b. Or use PowerShell: Get-Date -Format "yyyyMMdd". Or use WMIC: WMIC OS GET LocalDateTime and extract first 8 characters.

Why does my batch script show the wrong date?

Check your system's Regional Settings—DATE output format depends on locale. Also verify system date is correct: DATE /T shows current system date, which may be wrong if time sync is broken or CMOS battery is failing.

Can I use DATE to check if today is a weekend?

Yes, check if DATE /T output contains "Sat" or "Sun": DATE /T | FINDSTR /C:"Sat" /C:"Sun" returns 0 (found) on weekends. Or use PowerShell: (Get-Date).DayOfWeek returns day name.

How do I synchronize date across multiple computers?

For domain computers, ensure all systems sync with domain controllers: w32tm /resync. For workgroup computers, configure Windows Time service to sync with external NTP servers: w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /update.

Does DATE work in PowerShell?

Yes, but PowerShell users typically use Get-Date cmdlet which provides richer functionality. DATE works in PowerShell but returns a string, while Get-Date returns a DateTime object with methods and properties.

How do I validate user-entered dates in batch scripts?

Parse the input and check ranges: month 1-12, day 1-31, year 1980-2099. Or attempt to set the date with DATE user-input and check %ERRORLEVEL%—invalid dates return non-zero error codes.

Related Commands

TIME

Displays or sets the system time. Use alongside DATE for complete date/time management. TIME /T displays time without prompting, TIME HH:MM:SS sets time.

When to use: Use TIME with DATE for complete timestamp creation: ECHO %DATE% %TIME%. Use TIME to set system time when DATE sets the date.

WMIC OS GET LocalDateTime

WMI command that returns date and time in YYYYMMDDHHMMSS format, independent of Regional Settings. More reliable than DATE for international scripts.

When to use: Use WMIC OS GET LocalDateTime when scripts must work across all locales without date format parsing issues. Output is consistent worldwide.

Get-Date (PowerShell)

PowerShell cmdlet that returns DateTime objects with rich formatting, arithmetic, and comparison capabilities. Far more powerful than DATE for complex date operations.

When to use: Use Get-Date in PowerShell scripts for date arithmetic, custom formatting, and date comparisons. Use DATE in CMD/batch scripts for simplicity.

w32tm (Windows Time Service)

Manages Windows Time service for time synchronization with NTP servers and domain controllers. Use to configure time sync and troubleshoot time drift.

When to use: Use w32tm /resync to force time synchronization after manually setting date, or w32tm /query /status to check time sync configuration.

NET TIME

Legacy command to display or synchronize time with network servers. Deprecated in favor of w32tm but still available for backward compatibility.

When to use: Use NET TIME \\server /SET /YES to sync time with a specific server. Prefer w32tm for modern Windows systems.

SYSTEMINFO

Comprehensive system information command that includes OS installation date, last boot time, and other date-related information alongside full system configuration.

When to use: Use SYSTEMINFO | FINDSTR /C:"Original Install Date" to see when Windows was installed. Use DATE for current date only.

Quick Reference Card

CommandPurposeExample Use Case
DATE /TDisplay current dateQuick date check, scripts
DATEDisplay and prompt to changeInteractive date setting
DATE 12-25-2026Set date directlyAutomated date change
%DATE%Environment variable with dateFast date access in scripts
DATE /T > date.txtSave date to fileDate logging
FOR /F %%a IN ('DATE /T')Parse date in scriptDate component extraction
DATE /T | FINDSTR "Mon"Check day of weekDay-dependent logic
ECHO %DATE% %TIME%Complete timestampLog entries, audit trails
DATE /T & TIME /TDisplay date and timeQuick system time check
WMIC OS GET LocalDateTimeLocale-independent dateInternational scripts

Try It Yourself

Ready to master Windows date management? Practice using the DATE command in our interactive Windows Command Simulator. Experiment with date display, parsing, and build your command-line expertise in a safe, risk-free environment.

Launch the Windows Command Simulator to start practicing DATE commands now.

Want to explore more Windows commands? Check out our Complete Windows Commands Reference for detailed guides on over 200 CMD commands, including system information, file management, networking, and process control tools.

Related Guides:

Summary

The DATE command is an essential tool for Windows command-line users, providing quick access to system date information and modification capabilities. Whether you're using DATE /T for non-interactive date display in scripts or DATE for interactive date setting, this simple command delivers essential date functionality for logging, timestamping, and date-dependent automation.

We covered DATE command syntax including the /T parameter for non-interactive display, direct date setting with DATE MM-DD-YYYY, and ten practical examples demonstrating date display, parsing, timestamp creation, and date-based conditional logic. The command works across all Windows versions but output format varies by Regional Settings, requiring careful parsing in international deployments.

Key use cases include timestamped log file creation, date-based backup directory organization, audit trail logging, day-of-week validation for scheduled tasks, file retention automation, and date-dependent conditional logic. Batch script developers rely on DATE for generating date-based filenames, creating audit trails, and implementing date-dependent business logic.

Remember to always use DATE /T or %DATE% in batch scripts to prevent interactive prompts that would cause scripts to hang. Account for Regional Settings differences when parsing DATE output, or use WMIC or PowerShell for locale-independent date handling. Changing system date requires administrator privileges—always run CMD as administrator when scripts need to modify the date.

Practice using DATE regularly to build familiarity with date formatting and parsing techniques. The more you integrate DATE into your scripting workflows, the faster you'll create robust date-based automation, troubleshoot date-related issues, and maintain comprehensive audit trails. Start with simple date display and logging, then expand to date parsing and conditional logic as your confidence grows.