Decipher Code

  • Been trying to figure this out... what exactly are the date calculations doing in the code below:

    select join_date from company where join_date <= convert(varchar(10),(dateadd(day, -1*day(dateadd(month, 0 ,getdate())),dateadd(month, 0 , getdate()))),101) Thanks. Rog

  • select convert(varchar(10),(dateadd(day, -1*day(dateadd(month, 0 ,getdate())),dateadd(month, 0 , getdate()))),101)

    --results:

    05/31/2009

    it is finding the last day of the month prior to today. then of course it's find data in your table that is earlier than that.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you!

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

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