.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MDX IIF Statement to compare Moday's Date

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :Sql Server

Hi, I basically want to caluate the previous week


SELECT Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0).lag(1) ON 0

However, if it's a Sunday then it should be:

SELECT Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0) ON 0

So what I did was the following:

    SELECT IIF(Tail(NonEmptyCrossJoin([Dim Date].[Year-Quarter-Month-Day].[Day Of Week])).&[7]
                ,Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0).lag(1)
                ,Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0)
                ) ON 0
    FROM OLAP_Cube

However, I get The syntax for '&' is incorrect.

Any ideas?









View Complete Post

More Related Resource Links

Compare Date in LINQ

Dear all, How to do in LINQ?? And below is correct or not if put string.format in LINQ??   Datetime updatedDate=DateTime.Now; string upddate=string.format("yyyy-MM-dd", updatedDate); var result=( from p in W_Order                   where string.format("yyyy-MM-dd", p.orderdate) == upddate                    select new order {                       .........                        }).toList();            

How to use compare validator with dd/MM/yyyy format of date

Hi all,  I have a form of leave application that has 2 dates, start date and end date. now i'm using the dd/MM/yyyy format for the date entry and i need to Validate end date like end date must me greater than or equal to start date. i want to do that with compare validator but its not working properly because of the Date  formats controls are using.    Currently i'm using textbox with Calendar extender ajax toolkit control.    So please help me if anybody have some hints.    Thanks in advance.

how do it i created a Grid view that contain onecoloum Expiredate a i require the date compare to


i created a Grid view that contain onecoloum Expiredate a  i require the date compare to today date if it is

  Todaydate<=Expiredate (difference 30 days then color is red
  Todaydate<=Expiredate (difference 15 days then color is blue
  Todaydate<=Expiredate (difference 5 days then color is yellow
    id Expire date  Filename
    1  22/08/10      a(Red )   
    2  22/09/10     b(yellow )
    3  8/09/10      c(green  )
    how do it

SQL Statement to pull Date Effective Record


I have a set of requirments that require me to pull relative supporting data pulled based upon a date effectiveness.  For example, if I where to pull a record for dated 9/1, then I would want to pull the most recent supporting data.  I have accomplished this by using a Case Statement for three scenerios.  The first is where a date is found, the second is where no date is found but records exist, and the third is where no records are found.  The first two work perfectly, the last where where I am having some issue.  The statement reads like this:

    FROM   SupportTable AS Detail
    WHERE ([Master].ID = [Detail].MasterID)
    AND   (Date < @Date)) IS NOT NULL --This parameter can be pased in to the Stored Procedure,
     THEN ((SELECT MAX(Date) AS              --Retrived from the Master Table, or just using GetDate()
    FROM   SupportTable AS Detail
    WHERE ([Master].ID = [Detail].MasterID)
    AND   (Date < @Date))

Correct Syntax for a Select statement with a date in VB.net 2008 web developer


What is the correct syntax in VB.net 2008 web developer in SQL to do a WHERE clause where the data is >= to the current date? I can't figure out how you pass now into the SQL statement.

compare date field in sharepoint designer without considering time



I  set date1 field in sharepoint designer with “set field in current item” action. And in next step I want to compare date1 with another date field. With “if date1 not equal to date2”

although I set  “Date & Time Format” to “Date only”, my problem is sharepoint designer consider time ( although my condition is true ,I think its compare the time of my date field and cant go next step) and I don’t want it. I want to compare date filed only with date,

what should I do, that sharepoint designer only consider Date in Date field in action?

Thanx a lot.

SharePoint Designer Workflow - how to compare the Items if it is modified date is older than 20 days


I have a workflow which will keep track of specific meta data selection for a Custom List, as soon as an item gets updated to a specific selection say it as Resolved, I am sending an email to an user.


But after this I will need to check for every item in the list that If an item gets resolved and older than 20 days, I will have to move this item to a different list. I can get the resolved item date, store it an variable, but from here I will need to check if the item is older than 20 days and if it is this needs to be moved.

My point is the work-flows will be fired only when an item gets changed or updated, how to keep track of every item in the list and automatically move the older items without any manual intervention.


Am I clear in my requirement, if not kindly let me know.

If you have knowledge, let others light their candles in it.

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

jQuery Date picker Implementation in ASP.NET

I've posted a wrapper ASP.NET around the jQuery.UI Datepickercontrol. This small client side calendar control is compact, looks nice and is very easy to use and I've added it some time back to my control library.

This is primarily an update for the jQuery.ui version, and so I spend a few hours or so cleaning it up which wasn't as easy as it could have been since the API has changed quite drastically from Marc's original implementation. The biggest changes have to do with the theming integration and the resulting explosion of related resources.

If you want to use this component you can check it out a sample and the code here:

How to format datetime & date with century?

Execute the following Microsoft SQL Server T-SQL datetime, date and time formatting scripts in Management Studio Query Editor to demonstrate the usage of the multitude of temporal data formats available and the application of date / datetime functions.


Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend