Monday 24 March 2014

Script Library - Windows Batch - Generic Date Value

Script Library is my collection of reusable component as plugable script to get DATE value to be used in Windows Batch Scripting.

The scripts have the same usage but is written using different approach depending your needs:
  1. Script 1: Batch command [Date /T]
  2. Script 2: VBScript
  3. Script 3: Powershell
Have a great day


How To Include In Script

1. You can either embed the script block in your own script.

2. You can save the script in the file and include "CALL" command to activate.
     eg. CALL YLNotes_ScriptLibrary_Windows_GenericDateValue_0001.cmd



Date Value Usage

The Date Value is prefix with "d' which refers to date.
The detail reference of date usage are shown below table


Example of Date Value in Windows Batch Scripting:

1. To generate date timestamp "YYYYMMDD"
     ECHO %dYYYY%%dMM%%dDD%

2. To generate Today Date with format "dd-MM-YYYY" like "01-Mar-2014"
     ECHO %dDD%-%dMMM%-%dYYYY%

3. To generate Today Date with format "dd/MM/YYYY" like "01/03/2014"
     ECHO %dDD%/%dMM%/%dYYYY%

4. To generate Today Date with format "d/M/YY" like "1/3/14"
     ECHO %dD%/%dM%/%dYY%



Script Library

No comments :

Post a Comment