DateTimeToString method (WinStudio scripts)

Applies To

IWSApplication interface

Definition

Returns a date, time, or both, as a string formatted for the language in use by the WinStudio client or formatted as specified in a parameter passed to the method.

Syntax

Application.DateTimeToString( string1 [, string2, Boolean ] )

  Part   Description
string1 Required. A value that represents a date, time, or both.

The format must follow that of the format settings as explained in the "Format Settings" section below.

string2 Optional. A value that specifies the return format for the date, the time, or both. If a return format is not specified, the return value is formatted according to the WinStudio client language. See the "Format Settings" section below.

If you use this option, you should also include the Boolean option. It makes little sense to use one without the other.

Boolean Optional. Boolean value that instructs the system whether or not to apply the format defined in string2.
  • TRUE: Applies the Format specification to the return value regardless of the WinStudio client language.
  • FALSE: (Default) Does not apply the Format specification to the return value.

Format Settings

A format is defined by combining the following settings:

     g M/D/Y h:m:s p

Settings are case-sensitive.

  Part      Description
g Emperor era, used in Japanese, Korean, and other East Asian languages
M Month
D Day
Y Year
/ Date separator
h Hour
m Minute
s Second
p AM or PM
: Time separator

Remarks

If the string1 argument or the string2 argument is invalid, the return value is an empty string.

Example

This code sample shows return values with various settings and locales.

Dim strProp, strDate As String
   ' In these examples, the value of the property CheckDate is
   ' "2/3/2004 2:23:32 PM"
   strProp = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("CheckDate")
   strDate = Application.DateTimeToString(strProp)
   ' Value of strDate by locale:
   '   United States (English):  2/3/2004 2:23:32 PM
   '   Germany (German):  3.2.2004 14:23:32
   '   Netherlands (Dutch):  3-2-2004 14:23:32
   strDate = Application.DateTimeToString(strProp, "M/D")
   ' Value of strDate by locale:
   '   United States (English):  2/3
   '   Germany (German):  3.2
   '   Netherlands (Dutch):  3-2
   strDate = Application.DateTimeToString(strProp, "Y/D/M s:h:m", True)
   ' Value of strDate by locale:
   '   United States (English):  2004/3/2 32:2:23
   '   Germany (German):  2004/3/2 32:2:23
   '   Netherlands (Dutch):  2004/3/2 32:2:23
   strDate = Application.DateTimeToString(strProp, "h:m:s")
   ' Value of strDate by locale:
   '   United States (English):  2:23:32
   '   Germany (German):  2:23:32
   '   Netherlands (Dutch):  2:23:32