Skip to main content

Date functions specific to different databases

Database Specific Date Functions
=====The following table contains some of the most common database-specific date functions:

Database Specific Date Functions
The following table contains some of the most common database-specific date functions:


Database
DescriptionSQL ServerOracleDB2 UDBTeradata
Retrieve the database dategetdate()sysdatecurrent datedate
Convert a string to a datecast ('2001/01/20' as datetime)To_Date('2002-01-20', 'YYYY-MM-DD')cast ('01/20/2002' as date)cast ('2001/01/20' as date)
Get the day from a datedatepart(day, date_id)to_number(to_char(date_id, 'DD'))day(date_id)extract (day from date_id)
Get the month from a datedatepart(month, date_id)to_number(to_char(date_id, 'MM'))month(date_id)extract (month from date_id)
Subtract one month to a datedateadd(month, -1, date_id)add_months(date_id, -1)date_id - 1 monthsadd_months(date_id, -1)
Subtract one day to a datedateadd(day, -1, date_id)date_id -1date_id - 1 dayscast(date_id as date) - 1

For more information on using these functions in the MicroStrategy's architecture, refer to the MicroStrategy Product documentation and the following Microstrategy Knowledge Base document:


  • TN3905 (TN5200-7X0-0019): How to use pass-through expression- ApplySimple in MicroStrategy SQL Generation Engine 8.x

  • TN3905 (TN5200-7X0-0019): How to use pass-through expression- ApplySimple in MicroStrategy SQL Generation Engine 8.x
Also Custom Week function can be written in SQL for Vertica as :
select distinct date_trunc('week', (a11.datetime)) AS Week,
('Week '|| WEEK_ISO(a11.datetime) || ' / ' || a11.year_sid) AS WeekDesciption
from mstr_datamart.date_dim a11

Comments

Popular posts from this blog

Case functions Microstrategy

Ca se functions Microstrategy Case functions return specified data in a SQL query based on the evaluation of user-defined conditions. In general, a user specifies a list of conditions and corresponding return values. Case This function evaluates multiple expressions until a condition is determined to be true, then returns a corresponding value. If all conditions are false, a default value is returned.  Case  can be used for categorizing data based on multiple conditions. This is a single-value function. Syntax Case ( Condition1 ,  ReturnValue1 ,  Condition2 , ReturnValue2 ,...,  DefaultValue ) Example Case(([Total Revenue] < 300000), 0, ([Total Revenue] < 600000), 1, 2) sum(Case (Day@DESC in (“Sat”,”Sun”), Sales, 0) {~+} Sum(Case(Category@DESC In("Books","Electronics"),Revenue,0)){~+} CaseV (case vector) CaseV  evaluates a single metric and returns different values according to the results. It can be used to perform transf

Transaction Services - Configure Transactions

Configure Transactions in MSTR Web Transaction Services-enabled document displayed on an iPhone, iPad, or Android device can allow users to insert/update/delete data in to the database, using the options in the Configure Transactions Editor. To do so, you must link a Transaction Services report to a grid or to text fields in a panel stack. If the document is being displayed on an iOS device, you can link the report to the cells of a transaction table. Data from the input objects defined in the Transaction Services report is displayed in the grid, text fields, or cells for users to edit. Prerequisites:        Ø   You must have the Web Configure Transaction privilege assigned by MSTR user admin. Ø   Create the Transaction Services report (usually a grid report) you want to link to the grid, text fields, or transaction table cells. Make sure that the Transaction Services report must contain the input object for each value you want to allow users to change.  Ø   Ma

Update the data on an Intelligent Cube without having to republish the entire cube in MicroStrategy

Update the data on an Intelligent Cube without having to republish the entire cube in MicroStrategy MicroStrategy has introduced a feature known as, Incremental Refresh Options, which allow Intelligent Cubes to be updated based on one or more attributes, by setting up incremental refresh settings to update the Intelligent Cube with only new data. This can reduce the time and system resources necessary to update the Intelligent Cube periodically versus a full republish. For example, if a user has an Intelligent Cube that contains weekly sales data, the user may want this Intelligent Cube to be updated at the end of every week with the sales data for that week. By setting up incremental refresh settings, he can make it so that only data for one week is added to the Intelligent Cube, without affecting the existing data and without having to reload all existing data. Users can select two types of objects for the incremental fetch: a report or

Control the display of null and zero metric values

Show   Control the display of null and zero metric values in a grid report You can determine how to display or hide rows and columns in a grid report that consist only of null or zero metric values. You can have MicroStrategy hide the rows and columns in the following ways: Hide rows and columns that consist only of null metric values Hide rows and columns that consist only of zero metric values Hide rows and columns that consist only of null or zero metric values (default) Once you have defined how MicroStrategy hides null and zero metric values in the grid, you can quickly show or hide the grid using the Hide Nulls/Zeros option in the Data menu, as described below, or by clicking the  Hide Nulls/Zeros  icon  in the Data toolbar. To determine how null and zero metric values are displayed or hidden in a grid report Open the report in Edit mode. From the  Tools  menu, select  Report Options . The Report Options dialog box opens. To determine how

Stop a Report Services Document subscription from sending if no data is returned in MicroStrategy Web

Trick to Stop a Report Services Document subscription from sending if no data is returned in MicroStrategy Web The following steps are for stopping a Report Services Document subscription from sending if no data is returned: In MicroStrategy Web, edit or execute a report. Right-click on the metric header to apply the condition or threshold and select " Alerts ". Specify the condition " Is Not Null " to the metric for the delivery to be triggered in the filter editor as shown below. Expand the "Delivery Settings" section. Specify the desired delivery options including recipient address, subscription name, delivery format, compression options and the schedule to run the report and check the condition.  The subscription will be sent on the defined schedule only when data is returned in the Report Services Document.

Multi-Table Data Import(MTDI) from one or more supported data sources

Multi-Table Data Import(MTDI) from one or more supported data sources In MicroStrategy Analytics Enterprise Web 10 onewards, users can now simultaneously import two or more tables from one or more supported data sources, this feature is called Multi-Table Data Import (MTDI) which has been renamed as Super Cubes in MSTR 2019 (Does it sound like multisourcing for all the users without admin help?) Currently, all connectors in MicroStrategy Web 10 except " OLAP " and " Search Engine Indices " support Multi-Table Data Import. Users are able to add multiple tables/files when doing data import from single connector, as shown below: Users are also able to combine multiple tables/files from different sources and store them into one single Intelligent Cube, as shown below:

Export a Report Services document to Excel with formatting using URL API

Export a Report Services document to Excel with formatting using URL API in MSTR Web In order to export a document in excel format using the URL API, the executionMode must be set to 4.  If excutionMode is not provided in the URL, by default PDF will be used as executionMode.   Below are the list of parameters that the URL must contain in order to execute correctly.   evt= 3069 src= Main.aspx.3069 executionMode= 4 documentID= 7E1644CA424F482DA811569FCE8127FF( Replace the document Id with your document ID)   Sample URL for .NET environment: http://WebServerName/MicroStrategy/asp/Main.aspx?evt=3069&src=Main.aspx. 3069 &executionMode= 4 &documentID= 7E1644CA424F482DA811569FCE8127FF    

Personalizing file locations, email and file subscriptions using macros in Microstrategy

Personalizing file locations MSTr allows to dynamically specify the  File Location  and  Backup File Location  in a file device using macros.  For example, if you specify the  File Location  as  C:\Reports\{&RecipientName}\ ,  all subscriptions using that file device are delivered to subfolders of  C:\Reports\ . Subscribed reports or documents for each recipient are delivered to a subfolder with that recipient’s name, such as  C:\Reports\Jane Smith\  or  C:\Reports\Hiro Protagonist\ . The table below lists the macros that can be used in the  File Location  and  Backup File Location  fields in a file device: Description Macro Date on which the subscription is sent {&Date} Time at which the subscription is sent {&Time} Name of the recipient {&RecipientName} User ID (32-character GUID) of the recipient {&RecipientID} Distribution Services address that the subscription is delivered to {&AddressName} File path that a

Documents with derived attributes cannot be edited within MicroStrategy Developer 10.x

Documents with derived attributes cannot be edited within MicroStrategy Developer 10.x When trying to edit a document created in MicroStrategy Web using MicroStrategy Developer 10.x, the 'Edit' button is found greyed out and inaccessible as per the screenshot below. When navigating to the same document in MicroStrategy Web 10.x, it is possible to edit the document. STEPS TO REPRODUCE: Create a document in MicroStrategy Developer or Web 10.x with any number of attributes. See below: Notice in Developer, you can currently right click on this document and select the 'Edit' option. Open up the same document in MicroStrategy Web 10.x and add a derived attribute, right clicking an attribute and selecting Insert new attribute. Save the report in MicroStrategy Web 10.x with the same name. Open MicroStrategy Developer 10.x, and right click the document, you will notice that the Edit option is greyed out as seen below: Navigate to the same document wi

"System Prompt" and its uses in MicroStrategy

System Prompt and its uses in MicroStrategy WHAT IS A "SYSTEM PROMPT"? "System Prompt" is a system object that was introduced back in version 8.0.0. The object is named as "User Login" and is implemented as a prompt object. The object can be found under Public Objects > Prompts > System prompts, as shown below: Unlike ordinary prompt objects, system prompts don't require any answers from the user. When a report containing a system prompt runs, the prompt is answered automatically with the login of the user who runs the report. On the other hand, like other prompt objects, answers to system prompts are used to match caches. Therefore, users don't share caches for reports that contain system prompts. For details on how caches are matched, refer to the following MicroStrategy Knowledge Base document: KB5300-7X0-0147 - How are caches matched in MicroStrategy Intelligence Server 7.x? WHEN ARE SYSTEM PROMPTS USED?    System pr