Re: Working with dates ...

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Thu, 1 Feb 2007 05:14:01 -0800, Cameron Young <CameronYoung@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Script type ... NT batch scripting.
OS's ... Win2K, Win2K3

Am using the following script code to get the current date...
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Day=%%j
set Month=%%k
set Year=%%l
set Date=%%l-%%k-%%j
)

I'd like to be able to acquire the previous day's date, but not sure how I
can accomplish this in a batch script environment.

Can anyone assist in my query?
- - - - - - - - - - - - - - - - - - -
Cheers,
Cameron

The above script doesn't work on W2K3 because the date /t command doesn't return the day name.

To get todays date, regardless of NT version:

Call UnivDate
See tip 4835 » The Universal Date Parser, modified to also work with Windows XP.
in the 'Tips & Tricks' at http://www.jsifaq.com

see tip 8181 » How can I insure that a year, month, and day contain 4,2, and 2 digits, respectively?

See tip 8293 » How can I return the date that is plus or minus n days from today?

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
.



Relevant Pages

  • Re: How to change "regional and language options"?
    ... change the location by script or group policy? ... tip 3452 » Windows 2000 regional settings in the registry. ... Windows Server MVP ...
    (microsoft.public.windows.server.scripting)
  • Re: Join a domain and add user to local computer Admin group....
    ... computer startup script that can join a PC to a different domain? ... Install the Server Support Tools. ... See tip 3251 » Group Policy Restricted groups. ... How do I create a global group, so that it is a member of the local administrators group on all workstations and member servers, by using group policy restricted groups? ...
    (microsoft.public.windows.server.scripting)
  • Re: Working with dates ...
    ... "Jerold Schulman" wrote: ... Am using the following script code to get the current date... ... See tip 8293 » How can I return the date that is plus or minus n days from today? ... Windows Server MVP ...
    (microsoft.public.windows.server.scripting)
  • Re: Retrieve AD data
    ... Does anyone know a script to retrieve active directory data like ... See tip 9690 » How can a script return user properties using the LDAP provider? ...
    (microsoft.public.scripting.vbscript)
  • Re: script for showing locked accounts
    ... >Does anyone have a script that will display users who are locked out ... See tip 8549 » How can I report all locked accounts? ...
    (microsoft.public.win2000.active_directory)