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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:58:33+00:00 2026-06-03T08:58:33+00:00

I’m completely unfamiliar with windows scripting – I can roughly read it and see

  • 0

I’m completely unfamiliar with windows scripting – I can roughly read it and see what’s going on but when it comes to writing I’m basically at zero. Here’s what I’m trying to do.
I have the following script

echo on

SET LOGNAME=%7
SET LOGNAME=%LOGNAME%.log

Set CURRDATE=%TEMP%\CURRDATE.TMP
Set CURRTIME=%TEMP%\CURRTIME.TMP

DATE /T > %CURRDATE%
TIME /T > %CURRTIME%

Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYYMMDD=%%l%%k%%j%%i

Set PARSEARG="eol=; tokens=1,2,3,4* delims=:,. "
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMMSS=%%i%%j%%k%%l


sqlcmd -E -S %1 -d %2 -h-1 -b -w 1000 -Q "EXEC spTest %3,%4,%5 " -o %6Test_%YYYYMMDD%%HHMMSS%.DAT

IF ERRORLEVEL 1 GOTO FAILED

ECHO %YYYYMMDD% %HHMMSS% OK>>%LOGNAME%

GOTO END

:FAILED
ECHO %YYYYMMDD% %HHMMSS% FAILED>>%LOGNAME%

:END
EXIT /B %ERRORLEVEL%

Unfortunately from time to time the YYYYMMDD part of the file is missing (no idea why this happens – its very rare – I can only think it might be the odd network glitch). What I want to do is have an if statement so that if YYYYMMDD is empty I set it to some default date.
I was inserting the following line to my code – but this doesn’t do anything for me.

if %YYYYMMDD% ==" " (set %YYYYMMDD% =20990101)

Any advice please?

  • 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-03T08:58:35+00:00Added an answer on June 3, 2026 at 8:58 am

    Your IF statement is failing for two reasons – the comparison is wrong, and your syntax for the SET is wrong. I believe you want:

    if "%YYYYMMDD%"=="" (set YYYYMMDD=20990101)
    

    But I don’t understand why you need the above at all. I don’t know why you are getting intermitent failure, but it should be fixable.

    I do know your existing code can be greatly simplified. There is no need to use temporary files to capture the DATE and TIME values. Dynamic variables %DATE% and %TIME% provide the values you need. Type HELP SET for a list of available dynamic variables. And FOR /F can parse a string using IN("string") syntax. Type HELP FOR for a complete description of the command.

    Your code could be changed to look something like this:

    for /F %PARSEARG% %%i in ("%DATE%") do set YYYYMMDD=%%l%%k%%j%%i
    

    and

    for /F %PARSEARG% %%i in ("%TIME%") do set HHMMSS=%%i%%j%%k%%l
    

    Your existing PARSEARG definitions don’t look correct to me, and I think the assignment may have to change as well. Since I don’t know your locale settings or your desired output format, I can’t tell you exactly how to change it.

    If you can’t figure it out, post the format you get with %DATE% and %TIME%, as well as the format you want, and I (or someone else) can help further.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

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.