I want to extract the “month” from the date_contact column. I tried select dateadd(mm, datediff(mm,0, date_contact), 0)
from cohort
and select cast(date_contact As Date)
. I received result that is same as date from the first method. And for the second method I got error message: date_contact is not a valid name
.
Advertisement
Answer
select datepart(mm,date_contact) from cohort
aka..
select month(date_contact) from cohort
or…
select datename(mm,date_contact) from cohort