EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB20799: How to create a filter that returns the current year against a Microsoft SQL Server database


Stefan Zepeda

Salesforce Solutions Architect • Strategy


Users can create a filter that returns the current year from a SQL Server database by utilizing a built-in function called getdate( )

 
Users can create a filter that returns the current year from a SQL Server database by utilizing a built-in function called getdate( ). More information about this function can be read at the website:
 
http://msdn.microsoft.com/en-us/library/ms188383.aspx
 
Below is an example of how to use this current year found in the Strategy Tutorial project:
 

  1. Create a New Filter.
  2. Add an Attribute Qualification.
  3. Choose the attribute Year and qualify on its ID.
  4. Choose Operator as Exactly.
  5. Select Custom in the expression field and enter the following formula as shown below:

ApplySimple("datepart(year, getdate())",0)

ka02R000000kbW8QAI_0EM440000002EWr.jpeg

Note: The SQL query mentioned in this document is specific for Microsoft SQL Server and has been provided as a simple example to illustrate. If SQL is required for another database platform, users need to contact their database administrator to do so.
 
With this example above, the results that are returned will now only include those of the current year which is resolved by the database of SQL Server. Keep in mind that the Year attribute in Strategy's Tutorial Project is configured to have the ID match the year. Example 2000, 2001, 2002, etc. If users have their Year IDs stored differently in their Warehouses, they may need to adjust the ApplySimple being run appropriately.


Comment

0 comments

Details

Knowledge Article

Published:

June 16, 2017

Last Updated:

June 16, 2017