<p>I get to dust off my VBScript hat and write some classic ASP to query a SQL Server 2000 database.</p>

<p>Here's the scenario:</p>

<ul>
<li>I have two <em>datetime</em> fields called <strong>fieldA</strong> and <strong>fieldB</strong>.</li>
<li><strong>fieldB</strong> will never have a year value that's greater than the year of <strong>fieldA</strong></li>
<li>It <strong>is</strong> possible the that two fields will have the same year.</li>
</ul>

<p>What I want is all records where <strong>fieldA</strong> >= <strong>fieldB</strong>, <em>independent of the year</em>.  Just pretend that each field is just a month &amp; day.</p>

<p>How can I get this?  My knowledge of T-SQL date/time functions is spotty at best.</p>

```
```
select *
from t
where datepart(month,t.fieldA) >= datepart(month,t.fieldB)
      or (datepart(month,t.fieldA) = datepart(month,t.fieldB)
            and datepart(day,t.fieldA) >= datepart(day,t.fieldB))
```
```
If you care about hours, minutes, seconds, you'll need to extend this to cover the cases, although it may be faster to cast to a suitable string, remove the year and compare.
```
```
select *
from t
where substring(convert(varchar,t.fieldA,21),5,20)
         >= substring(convert(varchar,t.fieldB,21),5,20)
```
```