Commands & Syntax > Commands > Date & Time >

www.MacroToolworks.com

: DATE Insert or save to Variable - < date >() ... [Free]

 

Date & Time : DATE Insert or save to Variable
<date>(Format,"Separator",Day leading zero,Month leading zero,Day shift,"Variable for result","Date")
Available in: Free edition

The command inserts date information (e.g., 02/24/2000) in required format to the currently active window or saves it to required variable. The command uses current date and time unless other date/time is supplied as the last parameter.

 

#

Parameter name

Parameter description

1

Format

The date format. There are several formats predefined and can be referenced by number:
0 = DDMMYYYY
1 = MMDDYYYY
2 = DD
3 = MM
4 = DDMM
5 = MMDD
6 = MMYYYY
7 = DD_January_YYYY
8 = January_DD_YYYY
9 = Friday_X_January_DD_X_YYYY
10 = Friday_January_DD_X_YYYY
11 = Friday_DD_January
12 = Friday_DD_January_YYYY
13 = Friday
14 = January
15 = YYYY
16 = YY
17 = YYYYMMDD
18 = YYYYDDMM
19 = YYYYMM
20 = Windows user default - short
21 = Windows user default - long
22 = Format for calculations and compare

It is possible to define the format using a free form text with placeholders (for example, DD/MM/YY). Th eplaceholders are:
DD - the day (such as 23)
DN - the day name (such as Monday)
DW - the day of the week (such as 1)
MM - the month (such as 2)
MN - the month name (such as February)
YYYY - the year (such as 2019)
YY - two digits year (such as 19 for 2019)

Note: The format cannot contain comma character and brackets. Use a system variable such as %_vKeyBracketL%.

2

Separator

Separator character: .,/- etc.

3

Day leading zero

If 1, the day is displayed with leading zero (e.g., 02). If 0, the day is displayed without leading zero (e.g., 2).

4

Month leading zero

If 1, the month is displayed with leading zero (e.g., 09). If 0, the month is displayed without leading zero (e.g., 9).

5

Day shift

The date shift in days relative to the current date. 0 for no shift (today's date), -1 for date one day back (yesterday), +1 for date one day later (tomorrow), etc.

6

Variable for result

Variable that receives the date. If this variable name is an empty string, the date is send to active application as a set of keystrokes.

7

Date

Date input - the date to be used instead of the current date. It must be in ISO format (yyyy-mm-ddThh:mm:ss).

 

Example (Macro Steps):

 

1

<#> <#> Run this example in Notepad:

2

Current date is:

3

Date & Time : DATE Insert or save to Variable Format=MMDDYYYY, Separator=/, Day leading zero=Yes, Month leading zero = Yes, Day shift = 0, Variable for result =

4

\ Current date is:

5

Date & Time : DATE Insert or save to Variable Format=Friday January DD X YYYY, Separator=/, Day leading zero=Yes, Month leading zero = Yes, Day shift = 0, Variable for result =

6

\ Yesterday:

7

Date & Time : DATE Insert or save to Variable Format=MMDDYYYY, Separator=/, Day leading zero=Yes, Month leading zero = Yes, Day shift = -1, Variable for result =

8

\ 2020-11-23 in different format:

9

Date & Time : DATE Insert or save to Variable Format=Windows user default - long, Separator=/, Day leading zero=Yes, Month leading zero = Yes, Day shift = 0, Variable for result =

Example (Plain Text):

 

<#> Run this example in Notepad:

Current date is: <date>(1,"/",1,1,0,"")

Current date is: <date>(10,"/",1,1,0,"")

Yesterday: <date>(1,"/",1,1,-1,"")

2020-11-23 in different format: <date>(21,"/",1,1,0,"","2020-11-23")