+ Reply to Thread
Results 1 to 6 of 6

How can i convert the following IF statement into a CASE statement

Hybrid View

  1. #1
    Registered User
    Join Date
    07-17-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Question How can i convert the following IF statement into a CASE statement

    =IF(AND(Next Call Put Date < Active Maturity Date, Next Call Put Date <>1/1/2100,IF(Next Knockout Date <>1/1/2100,IF(Next Knockout Date < Next Call Put Date,1,0),1)),1,0)

    Any help appreciated - Thanks in advance.
    Last edited by speedo; 07-17-2012 at 10:54 AM.

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: How can i convert the following IF statement into a CASE statement

    ...so what's the question?

    I mean, presumably you want this to iterate somehow--a case statement?--but I have no idea what you want the future state of the logical assessments to be.

  3. #3
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: How can i convert the following IF statement into a CASE statement

    First, as Ben mentions, the question is unclear and there is no CASE statement in Excel (there is in VBA, though).
    Second, it is not even a case statement. That can all be reduced to:
    =--AND(NCPD < AMD, NCPD <>1/1/2100, NKD < NCPD)

    A case statement reacts to many different options, but when you can reduce it to 1 or 0, then all you need is an if statement.

    Pauley

  4. #4
    Registered User
    Join Date
    07-17-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How can i convert the following IF statement into a CASE statement

    I want to do convert the following Excel IF statement into an SQL query. Is this possible?

    The query is in MS Excel 2007 and yields the correct results:

    =IF(AND(Next Call Put Date < Active Maturity Date, Next Call Put Date <>1/1/2100,IF(Next Knockout Date <>1/1/2100,IF(Next Knockout Date < Next Call Put Date,1,0),1)),1,0)

    Can this be translated into a SQL statement - all date fields can be assumed as individual database fields. I want to be able to return the same FLAG as per the Excel IF statement.

    Thanks
    Last edited by speedo; 07-18-2012 at 02:59 AM.

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: How can i convert the following IF statement into a CASE statement

    Again, not sure if you need a case statement. Wouldn't something like this work?

    DECLARE @myflag bit;
    SET @myflag = (NCPD < AMD) AND (NCPD <> '2100-1-1') AND (NKD < NCPD);

    Note: I did shorten your names to their 'acronyms'. Also, you may get a better response at an SQL forum.
    Pauley

  6. #6
    Registered User
    Join Date
    07-17-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How can i convert the following IF statement into a CASE statement

    i guess it would be better putting this in a SQL forum.... thanks to all for their help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1