Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting a variable to system date

    I want to set the system date to a command line variable. I've tried SET SV=DATE where SV is the variable name--then when I type ECHO SV it returns the word DATE instead of the system date.

  2. #2
    Uranium Lounger
    Join Date
    Mar 2001
    Location
    New Jersey
    Posts
    6,684
    Thanks
    1
    Thanked 11 Times in 11 Posts

    Re: setting a variable to system date

    Does this help ??
    <IMG SRC=http://www.wopr.com/w3tuserpics/DocWatson_sig.gif>

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: setting a variable to system date

    The TIME variable is like the DATE variable. However, what I want to do is set a user-defined variable to the system variable DATE. The syntax of: SET SV=DATE sets the variable SV to the word "DATE" instead of the actual system Date. Same way with: SET SV=TIME. I must be overlooking part of the correct syntax.

  4. #4
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: setting a variable to system date

    In Windows 2000 and XP, there are two "built-in" command-prompt environment variables called %date% and %time%.

    If you are writing a BATch or ComManD file, you can put SET SV=%date% . Or just use %date% by itself. You may want to manipulate the content and order of the date subfields -- if so ask!

    Here's the output from my BATch file which contained:
    echo %date%
    set sv=%date%
    echo %sv%

    Note that this is what you get in the UK... your Regional and Language Options may differ...!

    C:JG>echo 25/08/2005
    25/08/2005

    C:JG>set sv=25/08/2005

    C:JG>echo 25/08/2005
    25/08/2005

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: setting a variable to system date

    I must be missing something:
    When I do this:
    Set SV=DATE
    echo %SV% --I get DATE

    Instead of Thu 08/25/2005

    Does typing these lines at the command prompt give different results than if run in a batch file?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: setting a variable to system date

    John wrote

    SET SV=%DATE%

    not

    SET SV=DATE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •