Navigation:  Reference > Modules, Conditional Output & Variables > Variables and Conditional Output >

Date & time formatting in variables

Print this Topic Previous pageReturn to chapter overviewNext page

A number of the predefined variables in Help & Manual enter the current date or time or the date or time associated with an item in your project. Normally these variables will automatically use the date and time format set in your Windows configuration. However, you can add a formatting string to the variable to change this if you want.

Note that this only works with variables that return date and time values, if you add format strings to any other variables the variable will no longer work. Also, you can only use this option on variable names entered in your topics – you cannot define variables with these formatting options.

 

       Key Information

You cannot DEFINE variables with date and time formatting information the format strings will fail in variable definitions. You can only use these options by editing variable names in the editor after inserting the variables.

Basic syntax

To use this feature you insert the variable in your project, either manually or with the Insert Variable tool, and then manually type a format string in parentheses inside the variable name in the Help & Manual editor:

<%NOW(format string)%>

Position and syntax of the format string:

The format string must be inserted in parentheses between the last letter of the variable name and the closing %> characters of the variable tag. The string can contain both "specifiers" that define the date and time format and normal text, which must be enclosed in double quotes.

Specifiers may be written in upper or lower case, the result will be the same.

Example:

This topic was last modified on  Donnerstag, Oktober 2, 2008,  at  10:57 AM

Result: This topic was last modified on Tuesday, January 3, 2007, at 12:22 PM

The text within the quotes will be inserted exactly as it is written. Any spaces required must be included within the quotes and the quotes must be separated from the specifiers by spaces.

Date and time format specifiers

Specifier

Function

" text "

' text '

Anything enclosed in single or double quotes is inserted unchanged as plain text and does not affect formatting.

. and ,

You can include periods and commas in the formatting string with the specifiers, these characters to not need to be quoted.

c

Displays the date using the standard Windows short date format, followed by the time using the standard Windows long time format. The time is not displayed if the fractional part of the DateTime value is zero.

d

Displays the day of the month as a number without a leading zero (1-31).

dd

Displays the day of the month as a number with a leading zero (01-31).

ddd

Displays the day as an abbreviation (Sun-Sat) using the standard Windows strings for short day names.

dddd

Displays the day as a full name (Sunday-Saturday) using the standard Windows strings for full day names.

ddddd

Displays the date using the standard Windows short date format.

dddddd

Displays the date using the standard Windows long date format.

m

Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mm

Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mmm

Displays the month as an abbreviation (Jan-Dec) using the standard Windows values for short month names.

mmmm

Displays the month as a full name (January-December) using the standard Windows values for long month names.

yy

Displays the year as a two-digit number (00-99).

yyyy

Displays the year as a four-digit number (0000-9999).

h

Displays the hour without a leading zero (0-23).

hh

Displays the hour with a leading zero (00-23).

n

Displays the minute without a leading zero (0-59).

nn

Displays the minute with a leading zero (00-59).

s

Displays the second without a leading zero (0-59).

ss

Displays the second with a leading zero (00-59).

z

Displays the millisecond without a leading zero (0-999).

zzz

Displays the millisecond with a leading zero (000-999).

t

Displays the time using the standard Windows short time format.

tt

Displays the time using the standard Windows long time format.

am/pm

Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.

ampm

Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the Windows TimeAMString global variable for any hour before noon, and the contents of the TimePMString global variable for any hour after noon.

/

Displays the date separator set in your Windows configuration.

:

Displays the time separator set in your Windows configuration.

See also:

Using Variables

 


Page url: http://www.helpandmanual.com/help/index.html?hm_ref_variables_dates.htm