Sybase 12.4.2 manual 214, Formatting times, Datetime format options

Models: 12.4.2

1 536
Download 536 pages 20.34 Kb
Page 234
Image 234

Converting data on insertion

The length of the format string is the width of the input column. Table 5-7 describes the date formatting options. The following table describes the time formatting options.

Table 5-9: Formatting times

Option

Meaning

hh

Represents hour. Hour is based on 24-hour clock. Always use

HH

leading zeros for hour where appropriate, for example ’01’ for 1

am. ’00’ is also valid value for hour of 12 am.

 

 

 

nn

Represents minute. Always use leading zeros for minute where

 

appropriate, for example ’08’ for 8 minutes.

 

 

ss[.ssssss]

Represents seconds and fraction of a second.

 

 

aa

Represents the a.m. or p.m designation.

 

 

pp

Represents the p.m designation only if needed. (This is

 

incompatible with Adaptive Server IQ releases prior to 12.0;

 

previously, pp was synonymous with aa.)

 

 

hh

Adaptive Server IQ assumes zero for minutes and seconds. For

 

example, if the DATETIME value you enter is ’03’, Adaptive

 

Server IQ converts it to ’03:00:00.0000’.

 

 

hh:nn or hh:mm

Adaptive Server IQ assumes zero for seconds. For example, if the

 

time value you enter is ’03:25’, Adaptive Server IQ converts it to

 

’03:25:00.0000’.

 

 

The following table shows examples of how time input data may look and how to specify the format for the DATETIME option. Following this table are the general rules for specifying times.

Table 5-10: DATETIME format options

Input Data

Format Specification

12/31/98 14:01:50

DATETIME (’MM/DD/YY hh:nn:ss’)

 

 

123198140150

DATETIME (’MMDDYYhhnnss’)

 

 

14:01:50 12-31-98

DATETIME (’hh:mm:ss MM-DD-YY’)

 

 

12/31/98 14:01:12.456

DATETIME (’MM/DD/YY hh:nn:sssssss’)

 

 

12/31/98 14:01:.123456

DATETIME (’MM/DD/YY hh:mm:sssssss’)

 

 

12/31/98 02:01:50AM

DATETIME (’MM/DD/YY hh:mm:ssaa’)

 

 

12/31/98 02:01:50pm

DATETIME (’MM/DD/YY hh:mm:sspp’)

 

 

Specification letters for time components must be in enclosed in parentheses and single or double quotation marks.

214

Page 234
Image 234
Sybase 12.4.2 manual 214, Formatting times, Datetime format options