Declare @ datestart datetime, @ dateend datetime, @ date datetime select @ date = getdate () -- select @ datestart = cast (floor (cast (@ date as numeric () + 1-day (@ date) as datetime) at the beginning of a month) -- end of a month select @ dateend = dateadd (MS,-3, dateadd (mm, 1, @ datestart) -------- start and end of a month select @ datestart, @ dateend -- start of a day select @ datestart = cast (floor (cast (@ date as numeric () as datetime) -- end of a day select @ dateend = dateadd (MS, -3, @ datestart + 1) -- select @ datestart, @ dateend -------------------------------------------------- select @ datestart = cast (floor (cast (@ date as numeric (18,10) + 1-day (@ date) as datetime) -- select @ datestart = dateadd (M,-month (@ datestart) + 1, @ datestart) -- last select @ dateend = dateadd (MS,-3, dateadd (year, 1, @ datestart) -- select @ datestart, @ dateend