dbTalk Databases Forums  

mdx formula to pick up the 1st day of the current month (system date)

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss mdx formula to pick up the 1st day of the current month (system date) in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
anasttin@excite.com
 
Posts: n/a

Default mdx formula to pick up the 1st day of the current month (system date) - 01-17-2006 , 09:49 PM






Hi all,

Is there an MDX formula I can use to pick up the 1st day of the system
date? I've looked at the available formulas and can't see any date
related ones at all.

Any help much appreciated.

Kind regards


Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: mdx formula to pick up the 1st day of the current month (system date) - 01-23-2006 , 03:30 AM






Are you talking about picking up the first day of the current month
based on the system date?

You can do this sort of thing using the Now() function in conjunction
with the StrToMember() function. It is hard to give a generic answer as
this depends on the structure of your time dimension. Below is an
example that works with the Time dimension in the Foodmart 2000 sample
database.

WITH
MEMBER Measures.DateStr as '"[Time].[1997].[Q" + format(now(),"Q") +
"].[" + format(now(),"m") + "]"'
MEMBER Measures.DateNow as 'StrToMember("[Time].[1997].[Q" + format
(now(),"Q") + "].[" + format(now(),"m") + "]").UniqueName'
SELECT
{Measures.DateStr,Measures.DateNow} ON COLUMNS
FROM Sales

I am returning the uniquename in the string as it is an easy way of
seeing which member the calculation is choosing. Starting off with a
calculated member like DateStr is an easy way to debug your expression
to make sure it is returning the string you need before placing it in
the StrToMember function (which will just return #Err if it does not
work)

HTH

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1137556141.631610.149860 (AT) f14g2000cwb (DOT) googlegroups.com>,
anasttin (AT) excite (DOT) com says...
Quote:
Hi all,

Is there an MDX formula I can use to pick up the 1st day of the system
date? I've looked at the available formulas and can't see any date
related ones at all.

Any help much appreciated.

Kind regards



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.