Lynn Pettis (3/14/2014)
vamsikrishnacheruku (3/10/2014)
hai i want to get the first date and weekday of every month in a year .1/jan/2014, monday
1/feb/2014,thrusday
, ,
,,
,,
,,,
,,,
,,
1/nov/2014, thrusday
1/dec/2014, friday
like this output should be
Can someone explain to me the weekdays? From what is posted above, it doesn't make any sense.
I ask because if you want the First of each month and the day it falls on, I cam up with this. Sorry Jeff, only coded it for a single year.
declare @Year date = getdate();
with TwelveCount(n) as (select n from (values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12))dt(n))
select
dateadd(month,n - 1, dateadd(year,datediff(year,0,@Year),0)) FirstOfMonth,
datename(dw,dateadd(month,n - 1, dateadd(year,datediff(year,0,@Year),0))) NameOfDay
from
TwelveCount
order by
dateadd(month,n - 1, dateadd(year,datediff(year,0,@Year),0))
I took it as meaning the first day of the month that does not fall on a Saturday or a Sunday, i.e., that is a "weekday", not a weekend-day.
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.