CRM 4.0’s Built-in SQL Functions (Part 4 of 5)

In this section, we’ll cover year-related functions.

You may wish to review the following articles before proceeding:

CRM 4.0’s Built-in SQL Functions (Part 1 of 5)

CRM 4.0’s Built-in SQL Functions (Part 2 of 5)

CRM 4.0’s Built-in SQL Functions (Part 3 of 5)

 

dbo.fn_BeginOfLastYear

Returns the beginning date and time for last year.

This function requires a valid datetime value.

select dbo.fn_BeginOfLastYear(GetUTCDate())

Returns: 2008-01-01 06:00:00.000

 

dbo.fn_BeginOfNextYear

Returns the beginning date and time for next year.

This function requires a valid datetime value.

select dbo.fn_BeginOfNextYear(GetUTCDate())

Returns: 2010-01-01 06:00:00.000

 

dbo.fn_BeginOfThisYear

Returns the beginning date and time for this year.

This function requires a valid datetime value. It is assumed you will specify today’s date and time.

select dbo.fn_BeginOfThisYear(GetUTCDate())

Returns: 2009-01-01 06:00:00.000

 

dbo.fn_BeginOfYear

Returns the beginning date and time of a year.

This function requires a valid datetime value.

select dbo.fn_BeginOfYear(GetUTCDate())

Returns: 2009-01-01 06:00:00.000

 

dbo.fn_EndOfLastYear

Returns the ending date and time for last year.

This function requires a valid datetime value.  It is assumed you will specify today’s date and time.

select dbo.fn_EndOfLastYear(GetUTCDate())

Returns: 2009-01-01 06:00:00.000

 

dbo.fn_EndOfNextYear

Returns the ending date and time for next year.

This function requires a valid datetime value.  It is assumed you will specify today’s date and time.

select dbo.fn_EndOfNextYear(GetUTCDate())

Returns: 2011-01-01 06:00:00.000

 

dbo.fn_EndOfThisYear

Returns the ending date and time for this year.

This function requires a valid datetime value.  It is assumed you will specify today’s date and time.

select dbo.fn_EndOfThisYear(GetUTCDate())

Returns: 2010-01-01 06:00:00.000

 

dbo.fn_LastXYear

Returns the date from X number of years ago ( from today ).

This function requires a valid datetime value.  It is assumed you will specify today’s date and time.

select dbo.fn_LastXYear(GetUTCDate(), 1)

Returns: 2008-08-16 05:00:00.000

 

dbo.fn_NextXYear

Returns a date that is X number of years in the future ( from today )

This function requires a valid datetime value.  It is assumed you will specify today’s date and time.

select dbo.fn_NextXYear(GetUTCDate(), 1)

Returns: 2010-08-17 05:00:00.000

Leave a Reply 0 comments