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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:18+00:00 2026-05-25T06:53:18+00:00

Assume that a reporting date is passed in that does not have leading zeros

  • 0

Assume that a reporting date is passed in that does not have leading zeros for the date month part. Normally it is passed in as param1 but below I am forcing a value for this example.

I would like to construct a string where teh month and year are extracted from the date that is passed in and construct a string in the format YYYY_MM where MM has leading zeros.

REM SET ReportingDate=%1 
SET ReportingDate=7/31/2011

@For /F "tokens=1,2,3 delims=/ " %%A in ("%ReportingDate%") do @( 
Set Month=%%A
Set Day=%%B
Set Year=%%C
)

echo Year=%Year%
echo Month=%Month%

SET NewFileName=MEMBOB_%Year%_%Month%.csv

Q: My knowledge of batch files is limited. What do I have do do to force a leading zero in the montgh when the date month is 1 digit long?

  • 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-25T06:53:18+00:00Added an answer on May 25, 2026 at 6:53 am

    Use an if-statement to prepend a 0 if the month is less than 10:

    if %Month% LSS 10 Set Month=0%Month%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Best practices in error reporting (Mathematica) Assume that I have a function
Assume that we have N erlang nodes, running same application. I want to share
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
Assume that I have this piece of code: @interface Foo : NSObject { Bar
Assume that a task exists with two attributes: priority and due date. Priority p
Assume that we have multiple arrays of integers. You can consider each array as
Assume that I only have a country code (en, de, fr) and I need
i have the following situation, i have a Reporting layer(stand alone) in asp.net application(NOT
I have some jQuery code that doesn't work as expected. $('a[href^=http://]').not('[href^=http://mydomain.com], [href^=http://itunes.apple.com]').click(function (e) {
I am building an mvc app for reporting. I have a page that has

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.