0% found this document useful (0 votes)
7 views2 pages

Sqlserver Class17

Uploaded by

hanuman sqlboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Sqlserver Class17

Uploaded by

hanuman sqlboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Conversion Functions: These functions are used to convert one data type to another.

We have two conversion functions are CAST and CONVERT both provide similar
functionality.

CAST (): Convert to one data type to another type.

Syntax: CAST (Expression as data type [size])

Ex: Select CAST (10.2587 as Int) -------------10

CONVERT (): Convert function can be used to display date time data in different format.

Syntax: Convert (Data type [size], Expression, Style value)

Ex: Select Convert (Varchar (24), get date (), 113)

The table below represents the style values for date time or small date time conversion
to character data:

no Value Output Standard

- 0 or 100 mon dd yyyy hh:mi AM (or PM) Default


1 101 mm/dd/yy USA
2 102 yy.mm.dd ANSI
3 103 dd/mm/yy British/French
4 104 dd.mm.yy German
5 105 dd-mm-yy Italian
6 106 dd mon yy
7 107 Mon dd, yy
8 108 hh:mm:ss
- 9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM) Default+millisec
10 110 mm-dd-yy USA
11 111 yy/mm/dd Japan
12 112 Yymmdd ISO
- 13 or 113 dd mon yyyy hh:mi:ss:mmm (24h)
14 114 hh:mi:ss:mmm (24h)
- 20 or 120 yyyy-mm-dd hh:mi:ss (24h)
- 21 or 121 yyyy-mm-dd hh:mi:ss.mmm (24h)
yyyy-mm-ddThh:mi:ss.mmm (no
- 126 ISO8601
spaces)
- 130 dd mon yyyy hh:mi:ss:mmmAM Hijiri
- 131 dd/mm/yy hh:mi:ss:mmmAM Hijiri

You might also like