I get to dust off my VBScript hat and write some classic ASP to query a SQL Server 2000 database.
Here’s the scenario:
- I have two datetime fields called fieldA and fieldB.
- fieldB will never have a year value that’s greater than the year of fieldA
- It is possible the that two fields will have the same year.
What I want is all records where fieldA >= fieldB, independent of the year. Just pretend that each field is just a month & day.
How can I get this? My knowledge of T-SQL date/time functions is spotty at best.
You may want to use the built in time functions such as DAY and MONTH. e.g.
Selecting all rows where either the fieldA’s month is greater or the months are the same and fieldA’s day is greater.