Calculate To Date

  • Hi to All,

    I have developing one windows application form using vb.net in this form i will enter from date,base currency,local currency . when i will enter the same base and local currency based on the new entry's from date it will calculate to date for the previous entry.

    example

    first entry

    fromdate todate basecurrency localcurrency

    07-04-2009 INR US

    second entry

    fromdate todate basecurrency localcurrency

    07-04-2009 14-04-2009 INR US

    15-04-2009 INR US

    got it?

    kindly any one give idea or sample code for me,it is very urgent.

    advance Thanks to all

    Anvar

  • I don't know whats your correct expectation But What I have , i given here

    ---if u want to get last date of current month---

    SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+1, 0)) AS DATE

    ---if u want to get last date of current with next month---

    SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+2, 0)) AS DATE

    Sorry for inconvenience ...

  • anvarabn (4/6/2009)


    When i will enter the same base and local currency based on the new entry's from date it will calculate to date for the previous entry.

    example

    first entry

    fromdate todate basecurrency localcurrency

    07-04-2009 INR US

    second entry

    fromdate todate basecurrency localcurrency

    07-04-2009 14-04-2009 INR US

    15-04-2009 INR US

    got it?

    Anvar

    Hmm.. no I don't understand the requirement. Or maybe I do, but I'm not sure. Is it like that:

    Whenever user enters certain combination of currencies and a date, you want to check your table for the last row with the same combination of currencies, that has NULL in the column "todate". Then you will update this row and put date by 1 day lower than the date entered into column "todate", and create a new row that will have the date entered in "fromdate", and "todate" is NULL.

    Generally said, when a new row is entered for certain combination, the previous row for that combination has to be "closed".

    Is that what you want?

  • Do an update where the base currency and local currency match on a self join on the table. The row to update would be the max FromDate less than the new entry.

    Heh... Got it?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply