Skip to main content
Inspiring
July 15, 2006
Question

Select records by date after first of next month

  • July 15, 2006
  • 1 reply
  • 337 views
Hi

I have an asp app accessing a SQL Server db and am getting myself into a tangle over dates. I have a date field ValidFromDt (smalldatetime) and another date field ValidUntilDt which respectively define when a record is valid from and until. I want to select all records valid on the first of next month - i.e. were now in July so I want any whose 'valid from' date is now or any day up to 1 Aug but excluding those which expire before 1 Aug and also those whose valid from date is 2 Aug or later. Whatever month we're in, it is the first of next month I want to select up until.

Any suggestions much appreciated.

Thanks

TP
This topic has been closed for replies.

1 reply

Participating Frequently
July 17, 2006
Try...

SELECT yourTable.* FROM yourTable WHERE CSng(Month([ValidFromDt]))>CSng(Month(Date()))