Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CONVERT() function in SQL Server

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 312
    Comment on it

    CONVERT()  function is basically used to converts an expression of one data type to another data type. This function display date/time data in different formats.

     

    Syntax:-
    CONVERT(data_type(length),expression,style)

    data_type(length):- It is used to specifies the target data type.

    expression:- It is used to specifies the value to be converted.

    style:- It is used to specifies the output format for the date/time.

     

    Example 1:-
         In this example we take a style value 108 which defines the following format:

    hh:mm:ss

    Now use the above style in the following query:

    select convert(varchar(20),GETDATE(),108)

    Output:-

    15:05:30

     

    Example 2:-

    In this example we use the style value 107 which defines the following format:

    Mon dd, yy

    Now use that style in the following query:

    select convert(varchar(20),GETDATE(),107)

    Output:-

    September 23, 2016

     

     

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: