Toad World® Forums

TOAD, SQL SERVER, date fields Where clause

Hi.

What is the SELECT syntax to pull data “where year = 2012”

if my date field is Date(10)

Example:
2010-02-09

Thanks

WHP

SELECT YEAR(GETDATE())

or

SELECT YEAR(‘4/17/2013’)

or

SELECT DATEPART(YEAR, GETDATE())

Thanks itlnstln, however, not sure how to use it,

tried this in where clause, but not working.

WHERE k.CPT_AND_HCPCS_CD in (‘H0002’,‘H0012’,‘H0013’,‘H2001’,‘H2035’,‘H2036’,‘S0315’,‘S0316’,‘S0317’,‘S0320’,‘S0340’,‘S0341’,
‘S0342’,‘S9140’,‘S9141’,‘S9455’,‘S9460’,‘S9465’,‘S9470’,‘S9472’,‘S9473’,‘S9476’,‘T1023’,‘4242F’,
‘4500F’,‘H0018’,‘H0028’,‘H0037’)
and DATEPART(YEAR, GETDATE()k.STMT_THRU_DT) = 2012

Got it.

and DATEPART(YEAR, a.SERV_END_DT) = 2012

Thanks

WHP