Calculate date using dateadd and datepart type held in data

  • Dynamic sql.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Then I would have dynamic sql generating dynamic sql! I'm afraid it will disappear up it's own rear end! 😀

  • Then use CASE WHEN:

    ...

    WHERE CASE WHEN DateTimeInterval = 'mm'

    AND [LastRunDate] <= Dateadd(mm, -1 * [DateTimeValue], Getdate())

    THEN 1

    WHEN DateTimeInterval = 'dd'

    AND [LastRunDate] <= Dateadd(dd, -1 * [DateTimeValue], Getdate())

    THEN 1

    WHEN DateTimeInterval = ...

    ELSE 0

    END = 1

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Looks like a solution - I'll give it a try

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

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