getting the next month base on a date

  • How can i set up a date to show what the date + 30 is and if that date is not the first of the month to give me the next month's first date

    the situation is employees are elgible for benefits 30 days after they are hired, and

    hire + 30 and then the first of the next month right?

    So If say someone is hired on the 10th of august they actually will not be eligible until October 1.

    i have a select statement to get the hire date how can i implement this into that

    select hiredate from employees where id=@id

  • declare @DHire datetime

    select @dhire = '6/2/2008'

    select

    case

    when datepart(day, @dhire+30) = 1 then @dhire + 30

    else dateadd(day, -1 * datepart(day, @dhire+30), dateadd(month, 1, @dhire+30))+1

    end

    Test it with a few dates. Should give you what you need.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • that did it thanks

  • Just to be sure, does this mean anyone hired in February isn't eligible for benefits until 4/1?

    😎

  • yep 30 days is 30 days

    good thought though

  • Lynn Pettis (8/6/2008)


    Just to be sure, does this mean anyone hired in February isn't eligible for benefits until 4/1?

    😎

    Last company I worked for based its time-off policy on Jan 1, and on how many years you had worked there. An employee, hired on 2 Jan, got a full week less of paid time off than someone hired 2 days earlier. Similar policy on a lot of other stuff.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • With the exception of 1 company (2 if you include pre-existing conditions), I (and my family) have been eligible for benefits from date of hire (first deduction for benefits was for 2 months, month hired and the following month), and vacation was prorated during the first year, but increments were based on anniversary of date of hire. The credit union I worked at, it was 90 days (had to make through your probationary period) for benefits.

    😎

  • Yeah, it all depends on the company.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 8 posts - 1 through 7 (of 7 total)

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