Convert () function in SQL Server
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
Convert functions is usually used with date/time data type to convert a date in different formats. Below examples will show the different formats in which we can display the date/time data type using Convert function. In the below examples we use getdate() to get the current date and time of the database server.
select convert(varchar(40), getdate(), 0)
Result:-
Jan 25 2015 9:36PM
select convert(varchar(40), getdate(), 101)
Result:-
01/25/2015
select convert(varchar(40), getdate(), 102)
Result:-
2015.01.25
select convert(varchar(40), getdate(), 103)
Result:-
25/01/2015
select convert(varchar(40), getdate(), 104)
Result:-
25.01.2015
select convert(varchar(40), getdate(), 105)
Result:-
25-01-2015
select convert(varchar(40), getdate(), 106)
Result:-
25 Jan 2015
select convert(varchar(40), getdate(), 107)
Result:-
Jan 25, 2015
select convert(varchar(40), getdate(), 108)
Result:-
21:39:21
select convert(varchar(40), getdate(), 109)
Result:-
Jan 25 2015 10:19:15:583PM
select convert(varchar(40), getdate(), 110)
Result:-
01-25-2015
select convert(varchar(40), getdate(), 111)
Result:-
2015/01/25
select convert(varchar(40), getdate(), 112)
Result:-
20150125
select convert(varchar(40), getdate(), 113)
Result:-
25 Jan 2015 23:22:49:453
select convert(varchar(40), getdate(), 114)
Result:-
23:23:09:970
select convert(varchar(40), getdate(), 120)
Result:-
2015-01-25 23:23:37
select convert(varchar(40), getdate(), 121)
Result:-
2015-01-25 23:24:07.577
select convert(varchar(40), getdate(), 126)
Result:-
2015-01-25T23:24:29.860
select convert(varchar(40), getdate(), 127)
Result:-
2015-01-25T23:24:55.037
select convert(varchar(40), getdate(), 131)
Result:-
5/04/1436 11:25:23:483PM
From the above examples we can see that how we can use the Convert () function to display date time in different formats.
Discover more from Technology with Vivek Johari
Subscribe to get the latest posts sent to your email.
… [Trackback]
[…] Information on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you will find 48487 additional Info to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More on on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More on to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you can find 90024 additional Info on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Info to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More Information here to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you can find 19607 additional Information to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you will find 70702 more Information on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More Info here to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Information on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More Information here to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Info to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] There you will find 27961 more Information to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More here on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you will find 69292 additional Info to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you will find 83580 more Info to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Read More Info here to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Find More here to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]
… [Trackback]
[…] Here you will find 84310 additional Information to that Topic: techmixing.com/2015/01/sql-server-convert-function.html […]