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
 How to write this stored procedure?

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-18 : 14:12:01
I want to get all dates that are = to 08/14 but in any year example 1959,1960,2009 etc...

select * from bif_rif_oct09
where dob like'0814****'

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-18 : 14:14:39
WEHRE MONTH(dob) = 8 AND DAY(dob) = 14

It'll need to scan the data though, so if your table is huge, don't expect great performance.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-18 : 14:19:53
The dob field is a varchar so I got the datatype is out of date range???
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-18 : 14:47:17
Could you show us the format of dob then? Perhaps we can just do a SUBSTRING or similar.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-18 : 16:05:29
08142000

Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-18 : 16:58:24
Cool, just do this then:

WEHRE dob LIKE '0814%'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-03-18 : 21:14:27
Thanks so much!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-18 : 21:15:29
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -