--first day of the month
select
DATEADD(mm,
DATEDIFF(mm,0,getdate()), 0)
as first_day_of_month
-- first day of the year
select
DATEADD(yy,
DATEDIFF(yy,0,getdate()), 0)
as first_day__of_year
-- first day of the quarter
select
DATEADD(qq,
DATEDIFF(qq,0,getdate()), 0)
as first_day_of_quarter
-- last day of the current month
select
dateadd(ms,-3,DATEADD(mm,
DATEDIFF(m,0,getdate()
)+1, 0))
as last_day_of_current_month
--number of days remaining in current month
select
datediff(dd,
getdate(),
dateadd(ms,-3,DATEADD(mm,
DATEDIFF(m,0,getdate()
)+1, 0)))
as days_remaining_in_current_month

No comments:
Post a Comment