Format Date Time Action

Declaration

<AMTEXTFORMATDATETIME DATETIMEFORMAT="text" INCLUDEAMPM="yes/no" RETURNRESULT="text" ACTION="text" SPECIFIEDDATETIME="text" SPECIFIEDFORMAT="text" SPECIFIED12HOUR="yes/no" INCLUDEAMPM="yes/no" ADJUSTYEAR="number" ADJUSTMONTH="number" ADJUSTDAY="number" ADJUSTHOUR="number" ADJUSTMINUTE="number" ADJUSTSECOND="number">

See Also

Format Date Time Action-Setting Properties, Find Text Action, Get Subtext Action

Description

Converts a date and/or time into the specified format.

Practical Usage

Date and text manipulation. Used to modify a date value to so that it matches a required format. For example, the application being automated may require a date to be input in a specific format such as yyyy dd mm - this action would be used to modify the value accordingly.

Parameters

General Tab

Date Time Format

Text, Required
MARKUP: DATETIMEFORMAT="dd/mm/yyyy hh:nn:ss"

Specifies the format that should be used when the date is output.  

The following special characters are used to create a date format:

y = year
m = month  
d = day
h = hour
n = minute
s = second

hh = leading zero (03)
h = no leading zero (3)

Populate Variable with Result

Text [variable name], Required
MARKUP: RESULTVARIABLE="varname"

Must specify an already existing variable name to be populated with the formatted date.

12 hour format

Yes/No, Optional - Default yes
MARKUP: SPECIFIED12HOUR="no"

Specifies whether hours of the day will be based on a 12 or 24 hour clock.

Include AM/PM in result

Yes/No, Optional - Default no
MARKUP: INCLUDEAMPM="yes"

Specifies whether an AM or PM indicator should be added to the end of the formatted date time value. This option is only available when "12 hour format" is specified.

 

Advanced Tab

Action

Text, Optional default (current)
MARKUP: ACTION="specified"

Specifies the source of the date time value to be formatted. .  

The available options are:

Specified Date Time

Text , Required if Action is set to specified
MARKUP: SPECIFIEDDATETIME="6/12/2005 1:42:40 PM"

Specifies the date time to format when Action is set to "specified".

Will be in the format

Text , Required if Action is set to specified
MARKUP: SPECIFIEDFORMAT="dd/mm/yy hh:nn:ss"

Specifies the format that should be applied when attempting to read the date in "Specified Date Time".

Prompt Message

Text , Required if Action is set to prompt
MARKUP: PROMPTMESSAGE="Please select the date"

Specifies the message that should be used on the date an/or time prompt dialog box.

Prompt Type

Text [options], Optional - default is "datetime"
MARKUP: PROMPTTYPE="date"

Specifies whether the prompt dialog box should prompt for the date, the time, or both.

The available options are:

Adjust Year

Number, Optional - default is "0"
MARKUP: ADJUSTYEAR="-4"

Specifies the number of years the date should be adjusted by. A positive or negative number may be used.

Adjust Hour

Number, Optional - default is "0"
MARKUP: ADJUSTHOUR="-4"

Specifies the number of hours the date should be adjusted by. A positive or negative number may be used.

Adjust Month

Number, Optional - default is "0"
MARKUP: ADJUSTMONTH="-4"

Specifies the number of months the date should be adjusted by. A positive or negative number may be used.

Adjust Minute

Number, Optional - default is "0"
MARKUP: ADJUSTMINUTE="-4"

Specifies the number of minutes the date should be adjusted by. A positive or negative number may be used.

Adjust Day

Number, Optional - default is "0"
MARKUP: ADJUSTDAY="-4"

Specifies the number of days the date should be adjusted by. A positive or negative number may be used.

Adjust Second

Number, Optional - default is "0"
MARKUP: ADJUSTSECOND="-4"

Specifies the number of seconds the date should be adjusted by. A positive or negative number may be used.

Notes

Using Variables

All variables must be created before they can be used. This is done using the Create Variable <AMVARIABLE> action. Once created, variables can be set using the Set Variable <AMSET> action, or by certain actions that support populating variables. To get data out of the variables, in any action parameter, simply surround the variable name with percentage % signs (e.g. %varname%). Remember not to use percentage signs when specifying the name of a variable to populate, percentage signs are only needed to get data out.

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMVARIABLE NAME="thedate"></AMVARIABLE>
<AMTEXTFORMATDATETIME DATETIMEFORMAT="m/d/yyyy" 12HOURFORMAT="NO" RETURNRESULT="thedate" ADJUSTDAY="-1">
<AMMESSAGEBOX>yesterdays date was %thedate%</AMMESSAGEBOX>