SQL Server considerations - HxGN EAM - 12.00.00 - Feature Briefs - Hexagon

HxGN EAM Equipment Overview 360

Language
English
Product
HxGN EAM
Search by Category
Feature Briefs
HxGN EAM Version
12

As indicated above, all query examples listed in this brief are based on the Oracle database.

Below are some SQL Server examples to select or format a date that would work with above examples.

  • First day of the current month, but for last year

DATEADD( month, -13, dbo.F_LAST_DAY( GETDATE() ) + 1 )

  • First day of the month three months ago

DATEADD( month, -4, dbo.F_LAST_DAY( GETDATE() ) + 1 )

  • First day of the current month

DATEADD( month, -1, dbo.F_LAST_DAY( GETDATE() ) + 1 )

  • First day of the year two years ago

DATEADD( year, -2, DATEADD( year, DATEDIFF( year, 0, GETDATE() ), 0 ) )

  • Year of the current date

FORMAT( GETDATE(), 'yyyy' )

  • Year and month of the current date

FORMAT( GETDATE(), 'yyyy-MM' )