I am trying to export a list of member details that have an expiry date after 2019
|name |expiry | |------|----------| |arthur|2010-01-01| |ben |2018-05-17| |craig |2005-12-30| |dean |2021-09-02|
so I am just after
|name |expiry | |------|----------| |dean |2021-09-02|
I thought I could simply use the date in a WHERE clause
SELECT name, expiry FROM table WHERE expiry < GETDATE() AND expiry >= '2019-01-01'
However, it still returns the other entries and not sure why
Advertisement
Answer
Assuming that you are using SQL Server:
SELECT name, expiry FROM tmp WHERE expiry < GETDATE() AND expiry >= CONVERT(DATE, '2019-01-01', 102)