Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 like function

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-03-12 : 11:50:04
I am running a query in SQL 2005 against a database that includes a date field that is formatted like 0000-00-00 00:00:00.

There are 7 years in the database - from 2001 through 2007.

I only want 2007 in my result and have tried filtering it multiple ways.

Is there like function (E.G. (hosp_rpt.fy_end_dt is like '2007-00-00 00:00:00')) that will work?

Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-12 : 11:51:30
SELECT * FROM Table1 WHERE Col1 >= '20070101' AND Col1 < '20080101'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-12 : 11:52:51
[code]SELECT *
FROM hosp_rpt
WHERE fy_end_dt >= '20070101'
AND fy_end_dt < '20080101'[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-03-12 : 12:18:44
quote:
Originally posted by Peso

SELECT	*
FROM hosp_rpt
WHERE fy_end_dt >= '20070101'
AND fy_end_dt < '20080101'



E 12°55'05.63"
N 56°04'39.26"



That worked perfect, Peso. Thanks very much!
Go to Top of Page
   

- Advertisement -