Type conversion function

xiaoxiao2021-03-06  69

Type conversion function

Adaptive Server provides three data type conversion functions: Convert, INTTOHEX, and HEXTOINT.

The syntax of the convert () function:

Convert (DataType, Expression [, style])

This function can be used in the Select selection list, where the WHERE clause, and any place to exist in the expression.

Select Name, Convert (Char (8), SALARY) "Yuan"

From auths

WHERE SALY> 200

result:

Name

Xu Lingyan ??? 280.50 yuan

Zhang ???? 550.00 yuan

?

The style parameter in the Convert function provides multiple date display formats for DateTime or SmallDateTime to CHAR or VARCHAR. Style's digital parameters determine how the date is displayed. The year can be displayed as a two-digit (yy), or it can be displayed in 4 digits (YYY). For example, assigning a Style parameter to 100, you can get a 4-bit annual number, that is, a century value (YYY).

The following table lists the available values ​​of the style parameter and the various date formats that can be used. When using the STYLE parameter together with the SmallDateTime type, those formats including seconds and milliseconds will be displayed in their bit value.

STYLE?

Standard output format No century value?

? - 0 or 100 default MON DD YYYY HH: MIAM (or PM? 1 101 USA MM / DD / YY? 2 102 ANSI YY.MM.DD? 3 103 ENGLISH DD / MM / YY? 4 104 German Dd.mm .y? 5 105 Italian DD-MM-YY? 6 106?

DD MON YY? 7 107?

MON DD YY? 8 108?

HH: mm :: s? - 9 or 109 Default milliseconds MON DD, YYYY HH: MM: SSSAM (or PM)? 10 110 USA MM-DD-YY? 11 111 Japan YY / MM / DD? 12 112 ISO YYMMDD?

?

Select Convert (12), Getdate (), 102)

result:

1997.11.03

转载请注明原文地址:https://www.9cbs.com/read-120453.html

New Post(0)