Date functions  Mathematical functions

Chapter 2: Transact-SQL Functions

Date parts

The date parts, the abbreviations recognized by Adaptive Server, and the acceptable values are:

Date part

Abbreviation

Values

year

yy

1753 – 9999 (2079 for smalldatetime)

quarter

qq

1 – 4

month

mm

1 – 12

week

wk

1 – 54

day

dd

1 – 31

dayofyear

dy

1 – 366

weekday

dw

1 – 7 (Sun. – Sat.)

hour

hh

0 – 23

minute

mi

0 – 59

second

ss

0 – 59

millisecond

ms

0 – 999

When you enter a year as two digits (yy):

Milliseconds can be preceded either with a colon or a period. If preceded by a colon, the number means thousandths of a second. If preceded by a period, a single digit means tenths of a second, two digits mean hundredths of a second, and three digits mean thousandths of a second. For example, “12:30:20:1” means twenty and one-thousandth of a second past 12:30; “12:30:20.1” means twenty and one-tenth of a second past 12:30. Adaptive Server may round or truncate millisecond values when inserting datetime or time data, as these datatypes have a granularity of 1/300th of a second rather than 1/1000th of a second. You can use the time datatype for time information.





Copyright © 2005. Sybase Inc. All rights reserved. Mathematical functions

View this book as PDF