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

MicroStrategy URL API Parameters

MicroStrategy URL Structure The following table summarizes the root URL structure used for every request to MicroStrategy Web. Environment Main Application URL Administration URL J2EE http://webserver/MicroStrategy/servlet/mstrWeb http://webserver/MicroStrategy/servlet/mstrWebAdmin .NET http://webserver/MicroStrategy/asp/Main.aspx http://webserver/MicroStrategy/asp/Admin.aspx Every request sent to MicroStrategy Web calls a central controller. Parameters are appended to  Main.aspx  or  mstrWeb  (in a .NET and J2EE environment, respectively) to indicate to the controller how the request should be internally forwarded and handled. The following examples show a URL for accessing a MicroStrategy folder when the user does not have an existing session. The URL contains not only the parameters needed to connect to MicroStrategy Web, but also the parameters needed to log on and create a session. J2EE environment: <a href="http:...

Fact tables levels tables in Microstrategy explained

Fact tables levels in Microstrategy: Fact tables are used to store fact data. Fact tables should contain attribute Id's and fact values which are measurable. All the descriptive information about the fact tables should stored in Dimension tables either in Star Schema fashion or Snow Flake Schema fashion which is best suited to your reporting solution. Since attributes provide context for fact values, both fact columns and attribute ID columns are included in fact tables. Facts help to link indirectly related attributes using these attribute ID columns. The attribute ID columns included in a fact table represent the level at which the facts in that table are stored. So the level of a fact table in the Fact_Item_Day_Customer can be the attribute Id's which is at Day, Item & Customer Id level. For example, fact tables containing sales and inventory data look like the tables shown in the following diagram: Base fact columns ver...

Multi sourcing in freeform SQL report

Multi sourcing in freeform SQL report  It is not possible to multisource a Free Form SQL report.If you notice when you create FF SQL report one of the first things is to select the specific data source.   This kind of makes sense because it would be difficult to write SQL that would process on two different DBMS. Options to overcome this issue: (1) Create FF SQL report against one Datasource and configure Data mart to another.   Then all data is in one system. (2) Create a DB_LINK between the two sources.    The SQL can access tables from both.   If you want more security on this method you can create views on specific linked tables and limit access for MicroStrategy DB Connection user to the views.Sample Syntax for SQL Server Link to Oracle.First set up ODBC to Oracle instance.   And run the following script with your settings.

Scheduling a report or document to be sent to an FTP in MSTR

Scheduling a report or document to be sent to an FTP server You can have a report or document automatically delivered to a location on your FTP server on a specific schedule. To do so, you must subscribe to the report or document, as described in the steps below. You can customize your subscription by typing macros in the  File Name ,  Sub-folder , or  Zip File Name  fields. These macros are automatically replaced with the appropriate text when the report or document is delivered. For example, you create a subscription to a document. If you type  {&Project}  in the  File Name field, the name of the project in which the document is saved is displayed in the name of the document when it is delivered. • This procedure assumes that an administrator has already added your FTP server as a new device in Developer. Steps to do so are included in the  System Administrator Help . To send a report or document to an FTP server on a schedule ...

Save Personal View of Microstrategy Report/Dashboard

Save Personal View of Microstrategy Report/Dashboard Starting in MicroStrategy Web 9.3.0, it is possible to capture a view of the report / document that user is viewing at a particular moment. This feature is available for both Report and Document. Create Personal View option is located under Home Menu bar (see image below). Saved view is available under My Subscription page under Personal View Subscriptions (see second image below) Create Personal View option is located under Home Menu bar Saved view is available under My Subscription page under Personal View Subscriptions Saving a personal view of a report, document, or quick dashboard A personal view allows you to save your own custom view of a report, document, or quick dashboard. The personal view includes every change that you made to the report, document, or quick dashboard since you opened it, including: Creating metrics Filtering Pivoting Sorting Prompt answers for a r...

Clean uninstall MicroStrategy Analytics Enterprise using the Uninstallation Cleanup Utility

How to  clean uninstall MicroStrategy Analytics Enterprise using the Uninstallation Cleanup Utility CONSIDERATIONS/GUIDELINES : This Uninstallation Cleanup Utility is designed to remove the obsolete or leftover services, files and registries after uninstalling MicroStrategy products.  The goal of this cleanup utility is to remove the leftover files and registries after uninstallation to make the machine "cleaner" for a second time installation (it can solve some known downgrade installation issues).  The basic assumption for removing files is that the user installed MicroStrategy  in a path that contains the string "MicroStrategy" . If not, the files and certain registry keys will not be removed. Using the cleanup utility incorrectly can cause system-wide problems that may require re-installation of the Operating System.  This utility should always be tested in a test environment before being run in a production environment.   Lin...

Create an alert-based subscription in MicroStrategy Distribution Services

Create an alert-based subscription in MicroStrategy Distribution Services on Web Subscription to a report or Report Services document which will be executed when a certain conditional threshold is met based on another executing report. For example, a scheduled report executes which shows the Revenue by day for the past week. If the Revenue on any one day falls below a certain value, a subscription to another report or Report Services document can be triggered and delivered to a recipient. An alert based subscription can only be created directly on a report; however, another report or Report Services document can be delivered when the alert based subscription is triggered. Note: you need a grid report to create an alert and you cannot create if you want to create on a document with text boxes. The following example will walk through the basic steps on how to setup a subscription based on an alert like this: Follow the brief  steps bel...

Images in Microstrategy PDF Export shows Red X

When exporting a report containing an image attribute form (using an ApplySimple statement) to PDF in MicroStrategy Web 9.4.1 and 10.x, with the Intelligence Server running on Linux, the image in the exported PDF report appears as a red "X". When exporting a report containing an image attribute form (using an ApplySimple statement) to PDF in MicroStrategy Web 9.4.1 and 10.x, with the Intelligence Server running on Linux, the image in the exported PDF report appears as a red "X" as shown below: However, the images in the report display properly when the report is executed in MicroStrategy Developer and Web. Furthermore, when the report is exported to PDF on Desktop (with the original images saved in WebASPX\Images), the images in the report display properly, as indicated below: CAUSE This is expected behavior. When the report is displayed in MicroStrategy Developer and Web, or when the report is exported to PDF from MicroStrategy Dev...

Best Practices for using images in Microstrategy reports

Using images in Microstrategy reports On the I-Server we copy the images to the following folders: - Program Files (x86)\MicroStrategy\Developer\Images - Program Files (x86)\MicroStrategy\IntelligenceServer\Images - Program Files (x86)\Common Files\MicroStrategy\images To reference an image using relative path, the following locations are required to store the image in order to display in multiple MicroStrategy products.    Relative path sample: images/ logo.jpg To display images on: MicroStrategy Desktop, Web, Mobile, Distribution Services: * Additional Adobe Flash security rule applies when displaying images on Flash Dashboard For image to display on MicroStrategy Web Services:   Note: It is recommended that HTTP path should be used for reference image. User should consider using HTTP path to reference image and store image in an client accessible server for easier maintain and upgrading purpose ...

Prompt-in-prompt(Nested Prompts) in Microstrategy

Prompt-in-prompt(Nested Prompts) in  Microstrategy Nested prompts allows you to create one prompt based on the other and other bases on another, nested prompts allows us to prompt the highest level(Like year) to middle level(like Quarter, then to the low level(like Month). Here you can see how to  create a 3-level deep nested prompt that will prompt the user to select a year, then a quarter within that year, then a month within that quarter. Prompt-in-prompt is a feature in which the answer to one prompt is used to define another prompt. This feature is only implemented for element list prompts . The following procedure describes how to achieve this: Create the highest level filter. This is a filter which contains a prompt on an attribute element list. Create a filter on the attribute "Year." Click "prompt on attribute element list" and click "Next" through the rest of the screens to accept the default values. Do not set any additio...