Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8884349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:02:35+00:00 2026-06-14T21:02:35+00:00

At a windows command line, when typing Date we’re asked to type a date

  • 0

At a windows command line, when typing Date we’re asked to type a date value.
But what if we need to change the date to a value which is a memorized (and not type it)?

@echo off
set todaysdate=%date%
date 11/11/2012
date %todaysdate%

The last line shows this error: The system cannot accept the date entered. And then requires us to enter a date.

So what’s wrong? Do I need to change the variable’s type? Is it possible and how?


Update:

Problem: Thanks to dbenham, we now know that the problem lies with Date %todaysdate% and its alternative Set "Todaysdate=%DATE:/=-%" leading to: day of the week + Date.

Example: Date %todaysdate% and Set "Todaysdate=%DATE:/=-%" (at the 1st script line) will have value: Sat 11/24/2012. So when we ask date (at the last line) to have this value Sat 11/24/2012 it fails since date doesn’t accept this value which includes day of the week Sat.

Solutions: I now think of 2 solutions but I’m not sure if they’re applicable in cmd.

1st solution is to make a test to see if 1st script line set value includes day of the week (Sat, Sun…) and to trim day of the week.

2nd solution is to change type of 1st line variable, so whichever type the variable has we’ll change it to simple date without day of the week (Sun, Mon…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:02:36+00:00Added an answer on June 14, 2026 at 9:02 pm

    when you set todaysdate take only the last 10 characters (mm/dd/yyyy or dd/mm/yyyy depends on your locale).
    this should work:

    @echo off
    set todaysdate=%date:~-10%
    date 11/11/2012
    date %todaysdate%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run a windows command line tool from a php script on
How can I use the Windows command line to change the extensions of thousands
I am able to call the following exe using windows command line, but using
Is there a better windows command line shell other than cmd which has better
I need to do the following using cmd (Windows command line). I have one
I am trying to use chmod utility on windows command line but it does
I need to execute ssh from windows command line by providing password in a
I have a windows command-line application which must be executed in Mac OSX Lion.
I've created an Android application from Windows command line (not using Eclipse), how do
I developed a Windows command line tool using C, and compiled it in VC++,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.