user1342164 user1342164 - 2 months ago 9
SQL Question

SQL - Greater than date query not working

I am using the SQL query below and I would like to get only the records where the column "Last Update Date" is greater than or equal to 01/01/2016. Basically only records in 2016. When I use the query below, I don't get any errors but I am still getting every date returned not just 2016. Is there something wrong with my syntax?

[Entity Type Code],
[Replacement NPI],
[Employer Identification Number (EIN)],
[Provider Organization Name (Legal Business Name)],
[Provider Last Name (Legal Name)],
[Provider First Name],
[Provider Middle Name],
[Provider Name Prefix Text],
[Provider Name Suffix Text],
[Provider Credential Text],
[Provider Other Organization Name],
[Provider Other Organization Name Type Code],
[Provider Other Last Name],
[Provider Other First Name],
[Provider Other Middle Name],
[Provider Other Name Prefix Text],
[Provider Other Name Suffix Text],
[Provider Other Credential Text],
[Provider Other Last Name Type Code],
[Provider First Line Business Mailing Address],
[Provider Second Line Business Mailing Address],
[Provider Business Mailing Address City Name],
[Provider Business Mailing Address State Name],
[Provider Business Mailing Address Postal Code],
[Provider Business Mailing Address Country Code (If outside U S )],
[Provider Business Mailing Address Telephone Number],
[Provider Business Mailing Address Fax Number],
[Provider First Line Business Practice Location Address],
[Provider Second Line Business Practice Location Address],
[Provider Business Practice Location Address City Name],
[Provider Business Practice Location Address State Name],
[Provider Business Practice Location Address Postal Code],
[Provider Business Practice Location Address Country Code (If outside U S )],
[Provider Business Practice Location Address Telephone Number],
[Provider Business Practice Location Address Fax Number],
[Provider Enumeration Date],
[Last Update Date]
WHERE ([Healthcare Provider Taxonomy Code_1] IN ('122300000X', '1223G0001X'))
AND ([Last Update Date] >= '01/01/2016')


Use instead of ([Last Update Date] >= '01/01/2016') the following:

YEAR( [Last Update Date]) = 2016

to get all the records that updated in 2016