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 6991221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:28:07+00:00 2026-05-27T19:28:07+00:00

I can’t find a simple breakdown of the batch file syntax for extracting the

  • 0

I can’t find a simple breakdown of the batch file syntax for extracting the current day/month/year.

I have the following syntax for declaring a variable used as a directory name;

set folder=%date:~10,4%%date:~7,2%%date:~4,2%

Can anyone shed some light (or post a link) on what the tilde, the double percentage means? I can’t seem to fully decipher it from intuition alone.

  • 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-27T19:28:08+00:00Added an answer on May 27, 2026 at 7:28 pm

    The double percentage means absolutely nothing. It is simply a result of having two variable expansions side-by-side such as:

    echo %firstname%%lastname%
         \_________/\________/
          Two separate expansions.
    

    The tilde gives you a substring. In your case, %date:~10,4% gives you four characters at offset ten of the date environment variable (the year in this case since the format is likely Thu 29/12/2011, with offsets starting at zero).

    If you enter set /? at a Windows command pronpt, it will explain all the options for you, including the nifty trick of using negative offsets to extract from the end of the string.

    However, you should keep in mind that the date environment variable format depends on the locale so this simplistic string extraction is unlikely to work across all international versions of Windows (this bit me a couple of years back).

    A better solution is to use WMI to get the date components such as on Rob van der Woude’s excellent scripting pages, copied here for completeness:

    FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Dayˆ,Hourˆ,Minuteˆ,Monthˆ,Secondˆ,Year /Format:table') DO (
        IF NOT "%%~F"=="" (
            SET /A SortDate = 10000 * %%F + 100 * %%D + %%A
            SET /A SortTime = 10000 * %%B + 100 * %%C + %%E
            SET SortTime=0000000!SortTime!
            SET SortTime=!SortTime:~-6!
        )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can anyone recommend a good library for generating an audio file, such as mp3,
I have a jquery bug and I've been looking for hours now, I can't
Can anyone give me an example of how to return the following json simply
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can't figure out how to do this in a pretty way : I have
Can you have submenus with the top level set to checkable in WPF? I
Can anyone help me trying to find out why this doesn't work. The brushes
Can I convert a pdf to pcl file with ghostscript? I'm using Ghostscript 9.01

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.