Send feedback on this topic.
Teradata.Client.Provider
Culture Specific Formatting and Parsing Strings
.NET Data Provider for Teradata > Developer's Guide > Data Types > Period Data Types > Culture Specific Formatting and Parsing Strings

Each Period type will support the conversion to a string or parsing a string to create a Period type. The conversion of a period to a string does not take into account any cultural settings. When a period type is converted into a string the format will be as follows:

    (Beginning Bound,  Ending Bound)

For example, the ANSI string representation of a TdPeriodDate (G format specifier) is as follows:

    (2006-12-12, 2007-10-31)

Another format that is support is the Literal format (the L or l format specifier). When the literal format is specified, the string representation of the period will be in a format where the string can be used as a literal in a Teradata SQL statement. The literal string format of a period is as follows:

    Period'(Beginning Bound, Ending Bound)'

An example of the literal representation of a TdPeriodTimestampWithTimeZone is as follows:

    Period'(2006-12-12 01:00:00.23-08:00, 2007-10-31 12:00:00.31-0800)'

Format Specifiers

G Format Specifier -- ANSI string representation

When the G format specifier is used to convert a Period type to a string, the ANSI string representation of the type is returned. In this conversion all of the cultural information contained in DateTimeFormatInfo is ignored. Each of the types have the following ANSI representation:

ANSI Representation Format Examples Period Type

(yyyy-MM-dd, yyyy-MM-dd)

MM -- number (1-12) associated with month

(2001-12-10, 2011-12-10) TdPeriodDate

(HH:mm:ss.ffffff, HH:mm:ss.ffffff)

ffffff -- number of digits as specified by the Scale property

(12:31:21.998212, 13:00:00.000000)
(01:09:11, 15:21:00)
(21:54:01.0002, 21:54:01.0003)
TdPeriodTime

(HH:mm:ss.ffffffZ, HH:mm:ss.ffffffZ)

HH -- 24 hour time
Z -- UTC Offset in the format hh:mm

(02:43:12.0001-08:00, 04:34:00.0321-08:00)
(11:56:21+05:00, 20:06:12+05:00)
(18:07:02.00230+02:00, 18:07:02.00230-03:00)
TdPeriodTimeWithTimeZone
(yyyy-MM-dd HH:mm:ss.ffffff, yyyy-MM-dd HH:mm:ss.ffffff) (2010-12-15 22:10:03.0021, 2011-02-12 01:23:00.0000)
(2009-01-21 01:32:09, 2009-01-21 10:42:00)
TdPeriodTimestamp
(yyyy-MM-dd HH:mm:ss.ffffffZ, yyyy-MM-dd HH:mm:ss.ffffffZ) (2008-10-31 23:53:49.00201+09:30, 2008-11-23 00:00:00.00000+09:30)
(2011-06-17 11:00:00-02:00, 2011-06-17 23:00:50-02:00)
TdPeriodTimestampWithTimeZone

L or l Format Specifier -- Teradata String Literal for Date And Time Types

The ToString methods for each of the Period types support the conversion of the type into a string that is equivalent to the Teradata Literal representation. The format specifier L or l is used to perform this conversion.

The Teradata Literal representation is similar to the ANSI representation, except that the period is preceded by the keyword PERIOD and is surrounded by apostrohes. Cultural information is also ignored in the conversion. For example, the following are Teradata literal representations of a TdDate and TdTimestampWithTimeZone:

    PERIOD'(2001-10-04, 2001-10-05)', 
    PERIOD'(2005-01-20 14:32:00.212+09:00, 2005-01-21 19:06:30.999+09:00)'

Supported Format Specifiers

All the Period types will support the following format specifiers:
Format Specifier Description
G

Ansi representation of the period.

Example: (2008-10-31 12:00:00-08:00, 2008-12-15 01:30:00-08:00)

L or l

The Teradata string literal representation of the period.

Example: PERIOD'(02:43:10.321, 10:00:21.948)'

Although only two format specifiers are supported by the period types, the ToString method of the corresponding Date And Time type can be invoked on the begin and end bounds of a period type. The following examples demonstrates how this is performed.

An example of invoking the ToString method is as follows:

C#
Copy Code
    TdPeriodTime ts = new TdPeriodTime
        new TdTime(01, 43, 45, 000000, 0),
        new TdTime(10, 10, 00, 000000, 0);

    // The Period will appear in the string as (01:43:45, 10:10:00) for both of the calls to ToString
    String tmp1 = ts.ToString();
    String tmp2 = ts.ToString("G");

    // The Period will appear in the string as PERIOD '(01:35:45, 10:10:00)'
    String tmp3 = ts.ToString("L");

    // The ToString method of the corresponding Date And Time type 
    // is called to format the begin and end bounds of the period. 
    // The Period will appear in the string as ('01:43:45 AM', '10:10:00 PM') 
    String tmp4 = String.Format("('{0}', '{1}')", ts.Begin.ToString("T"), ts.End.ToString("T")); 

See Also

Reference

TdPeriodDate.ToString(String)

TdPeriodTime.ToString(String)

TdPeriodTimeWithTimeZone.ToString(String)

TdPeriodTimestamp.ToString(String)

TdPeriodTimestampWithTimeZone.ToString(String)