Home > Home, SQL Server 2012, TSQL > T-SQL 2012 New Functions

T-SQL 2012 New Functions

 

Date and time functions

  1. DATEFROMPARTS

Syntax:- DATEFROMPARTS(Year, Month, Day)

Arguments:- year Integer expression specifying a year.

                      month Integer expression specifying a month, from 1 to 12.

                      day     Integer expression specifying a day.

Return Type:– Date

DATEFROMPARTS

2. DATETIMEFROMPARTS

Syntax:- DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )

Arguments:-

year Integer expression specifying a year.

  month  Integer expression specifying a month.

  day      Integer expression specifying a day.

  hour     Integer expression specifying hours.

  minute Integer expression specifying minutes.

  seconds Integer expression specifying seconds.

  milliseconds Integer expression specifying milliseconds.

Return Type:- datetime

DATETIMEFROMPARTS

3. DATETIME2FROMPARTS

Syntax:- DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )

Arguments:- year Integer expression specifying a year.

  month  Integer expression specifying a month.

  day      Integer expression specifying a day.

  hour     Integer expression specifying hours.

  minute Integer expression specifying minutes.

  seconds Integer expression specifying seconds.

  milliseconds Integer expression specifying milliseconds.

Return Type:- datetime

DATETIME2FROMPARTS

4.SMALLDATETIMEFROMPARTS

Syntax:- SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute )

Arguments:-

  Year – Integer expression specifying a year.

  Month-Integer expression specifying a month.

  Day Integer expression specifying a day.

  Hour Integer expression specifying hours.

    Minute Integer expression specifying minutes.

Return Type:- smalldatetime

SMALLDATETIMEFROMPARTS

5.DATETIMEOFFSETFROMPARTS

DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision )

6.TIMEFROMPARTS

TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )

7.EOMONTH 

EOMONTH ( start_date [, month_to_add ] )

EOMONTH

  • Logical functions

    1. CHOOSE ( index, val_1, val_2 [, val_n ] ) 

      CHOOSE

    2. IIF ( boolean_expression, true_value, false_value )SELECT IIF ( 20 > 10, ‘true’, ‘false’ ) AS Result;

      SELECT IIF ( 45 > 30, NULL, NULL ) AS Result;

      DECLARE @P INT = NULL, @S INT = NULL;

      SELECT IIF ( 45 > 30, @p, @s ) AS Result;

  • String functions

    1. CONCAT ( string_value1, string_value2 [, string_valueN ] )CONCAT

    2. FORMAT ( value, format [, culture ] )FORMAT
  • Conversion functions

    1. PARSE ( string_value AS data_type [ USING culture ] )PARSE
    2. TRY_PARSE ( string_value AS data_type [ USING culture ] )TRY_PARSE
    3. TRY_CONVERT ( data_type [ ( length ) ], expression [, style ] )TRY_CONVERT
  • Sequence

    Sequence Objects

  • Offset

First mark the start of the row by using “OFFSET” command.

Second specify how many rows you want to fetch by using “FETCH” command.

offset

Hope you like this post.

Please provide your valuable feedback through liking the post or adding comments. It will help to encourage to do lot of similar stuff.

Thanks

Prasad

Learn Different BI Tools
Subscribe my YouTube Channel : Know BI Tools

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: