scedhule a job for the the Tuesday night after the last Friday each month

  • Ya, I just realized that I'm picking only in the same month... sorry about that.

    Thanks Michael.

  • Ninja's_RGR'us,

    Cool way to get just the date from today. I'd never seen that before. So, I tested it.

    DECLARE @test_dt DATETIME

    set @test_dt = DATEDIFF(D, 0, GETDATE());

    SELECT @test_dt

    SET @test_dt = DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) --Today without time

    SELECT @test_dt

    Both SELECT statements produced the same result.

    Is the DATEADD necessary? Am I missing something?

    LC

  • try it with assigning the result to a variable... there's a implicit cast in there you're not seeing.

  • I am missing something.

    Are my "SET" statements not assignments?

    DECLARE @test_dt DATETIME

    SET@test_dt = DATEDIFF(D, 0, GETDATE());

    SELECT@test_dt

    DECLARE @x DATETIME

    SET@x = @test_dt

    SELECT@x

    Both "SELECT" statements produce the same "timeless" timestamp.

    LC

  • Lee Crain (5/19/2011)


    I am missing something.

    Are my "SET" statements not assignments?

    DECLARE @test_dt DATETIME

    SET@test_dt = DATEDIFF(D, 0, GETDATE());

    SELECT@test_dt

    DECLARE @x DATETIME

    SET@x = @test_dt

    SELECT@x

    Both "SELECT" statements produce the same "timeless" timestamp.

    LC

    The point that was being made is that the following statement results in an implicit cast of the integer result of the DATEDIFF function to a datetime value.

    SET @test_dt = DATEDIFF(D, 0, GETDATE());

    The result is the same as this with the implict conversion made explicit:

    SET @test_dt =convert(datetime,DATEDIFF(D, 0, GETDATE()));

  • Oh, got it. Glad I didn't need to be clubbed over the head with it.

    :hehe:

    LC

Viewing 6 posts - 16 through 20 (of 20 total)

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