How convert data types using Convert () Function

  By Rizwan Saqib   Posted on March-22-2018   691

MS Sql Server

Convert() Function

When you convert expressions from one type to another, in many cases there will be a need within a stored procedure or 
other routine to convert data from a datetime type to a varchar type. The Convert function is used for such things. 
The CONVERT() function can be used to display date/time data in various formats

For example

We have Getdate function

Select Getdate() as Current_Datetime 

It give us current datetime like this   [ 2018-03-22 17:40:17.040 ]

If we want to convert Datetime in other format first we conver Datatype

Select convert(varchar(20),GETDATE(),109)

Now it give us Datetime format like this   [Mar 22 2018  5:44:29]

By  Rizwansaqib966    22-Mar-2018 Views  691

You may also read following recent Post

Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links