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

  • Home
  • SEARCH
  • 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 6353869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:29:08+00:00 2026-05-24T22:29:08+00:00

See Batch code below, it show a date and time but the day is

  • 0

See Batch code below, it show a date and time but the day is missing. How to fix this?

code:

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set dt=%%c-%%a-%%b)
For /f "tokens=1-4 delims=:." %%a in ('echo %time%') do (set tm=%%a.%%b)
set bkupfilename=%1 %dt% %tm%.bak
echo Backing up to file: %bkupfilename%

Output:

C:\wamp>backup.bat
Backing up to file:  -08-2011 15.49.bak
  • 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-05-24T22:29:09+00:00Added an answer on May 24, 2026 at 10:29 pm

    when parsing output of system commands like date /t, the system locale is very important.

    the first line of the script issues the command date /t and parses its output. it splits the string at specified delimiters, which are the space (hence the space before the end ") and the slash /. it then takes the 2nd to 4th items found and assign them to variables %a, %b and %c.

    if you type date /t on your console you will see the output and understand why the script is not working…

    • the system on which this command was written used american date format (month-day-year),
    • on my system, which uses european date format (day-month-year), the script works but invert the month and the day.

    i suppose that on your system, the ouput of the date /t command is different, due to your system locale settings. you will have to modify your script in order to comply to these settings.

    (also, keep in mind that this kind of script is not portable: another user using another locale will encounter the same kind of problems)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the first time I see this code myself where we are getting
I came across this piece of batch code. It should find the path to
How can a batch file by itself see where it is located?
I'd like to write a batch file that checks to see if a process
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
I have this code: FOR %%d IN (c d e f g h i
How do I set the batch size for Nhibernate? I'd like to do this
When I execute the batch file directly in DOS, everything runs as expected. But
I'm trying to upload images using Graph API Batch Request, but i'm unable to
To batch upload many files, there is one section of CSharp WPF code that

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.