Вы находитесь на странице: 1из 4

TRANSLATE

Search w3schools.com HOME HTML C SS XML JAVASC RIPT ASP PHP SQL MORE...
R EFER ENC ES | EXAMPLES | FO R UM

Search
| ABO UT

FREE SCRIPTS INSTALLER WordPress, Drupal, Zen Cart phpBB, Moodle, Gallery Open-Realty, osTicket & More

SQL Basic
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL HOME Intro Syntax Select Distinct Where And & Or Order By Insert Update Delete

SQL Server CONVERT() Function


SQL Server Date Functions

WEB HOSTING Best Web Hosting PHP MySQL Hosting Best Hosting C oupons UK Reseller Hosting C loud Hosting Top Web Hosting $7.95/mo SEO Hosting Premium Website Design WEB BUILDING

Definition and Usage


The CONVERT() function is a general function for converting data into a new data type. The CONVERT() function can be used to display date/time data in different formats.

Syntax
CONVERT(data_type(length),data_to_be_converted,style)
Where data_type(length) specifies the target data type (with an optional length), data_to_be_converted contains the value to be converted, and style specifies the output format for the date/time. The styles that can be used are: Style ID 100 or 0 101 102 103 Style Format mon dd yyyy hh:miAM (or PM) mm/dd/yy yy.mm.dd dd/mm/yy
New hot app: Facebook Albums To PDF

SQL Demo
SQL Try It

XML Editor - Free Trial! FREE Website BUILDER W3SCHOOLS EXAMS Get C ertified in: HTML, C SS, JavaScript, XML, PHP, and ASP W3SCHOOLS BOOKS New Books: HTML, C SS JavaScript, and Ajax STATISTICS Browser Statistics

SQL Advanced
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL Top Like Wildcards In Between Alias Joins Inner Join Left Join Right Join Full Join Union

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL

Union Select Into Create DB Create Table Constraints Not Null Unique Primary Key Foreign Key Check Default Create Index Drop Alter Increment Views Dates Nulls isnull() Data Types

104 105 106 107 108 109 or 9 110 111 112 113 or 13 114 120 or 20 121 or 21 126 130 131

dd.mm.yy dd-mm-yy dd mon yy Mon dd, yy hh:mm:ss mon dd yyyy hh:mi:ss:mmmAM (or PM) mm-dd-yy yy/mm/dd yymmdd dd mon yyyy hh:mm:ss:mmm(24h) hh:mi:ss:mmm(24h) yyyy-mm-dd hh:mi:ss(24h) yyyy-mm-dd hh:mi:ss.mmm(24h) yyyy-mm-ddThh:mm:ss.mmm(no spaces) dd mon yyyy hh:mi:ss:mmmAM dd/mm/yy hh:mi:ss:mmmAM

Browser Statistics Browser OS Browser Display SHARE THIS PAGE Share with

SQL Functions
SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL SQL Functions avg() count() first() last() max() min() sum() Group By Having ucase() lcase() mid() len() round() now() format()

Example
The following script uses the CONVERT() function to display different formats. We will use the GETDATE() function to get the current date/time:

CONVERT(VARCHAR(19),GETDATE()) CONVERT(VARCHAR(10),GETDATE(),110) CONVERT(VARCHAR(11),GETDATE(),106) CONVERT(VARCHAR(24),GETDATE(),113)


The result would look something like this:

SQL Quick Ref SQL Hosting SQL Summary

Nov 04 2008 11:45 PM 11-04-2008 04 Nov 08 04 Nov 2008 11:45:34:243

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

New hot app: Facebook Albums To PDF

pdfcrowd.com

SQL Quiz
SQL Quiz

SQL Server Date Functions

11,137,198 Sites built with Wix. Make your own!


Click here to design a Stunning Flash Website for Free Wix is a revolutionary web design tool that provides anyone with the possibility to create professional and beautiful websites for free. With e-commerce features, search engine visibility and many more professional tools, Wix is the ultimate solution for creating a spectacular site while saving tons of money. Create a Website, Its Free!

RE P O RT

E RRO R

HO ME

TO P

P RI N T

FO RU M

A BO U T

open in browser

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2012 by Refsnes Data. All Rights Reserved. New hot app: Facebook Albums To PDF PRO version Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

New hot app: Facebook Albums To PDF

pdfcrowd.com

Вам также может понравиться