• daniness - Friday, December 15, 2017 11:30 AM

    Hi J Livingston SQL,
    "CoverageEffectiveDateKey" is of the int datatype...it displays dates in the "yyyymmdd" format...it's actually a foreign key being used by several tables in the datamart here. Please let me know if I can further clarify anything else. Thanks!

    I'm just curious... why did they select the INT datatype to store dates when the DATE datatype is a byte less, does checking to ensure it's a real date, and easily allows for some date math.  INT doesn't allow for any of that directly.

    Also, your calculation is a bit confusing... you're using all Integer Math and yet you use the ROUND function.  What do you really want to use for the number of days in a month?  30 or 30.416666 or a more proper calculation based on the day of the month?

    --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)