T-SQL query - List this financial years transactions
Posted on 2012-04-10
I would like to list all transactions this financial year (from 31 March).
I have tried something like:-
WHERE (InvDate > DATEADD(m, CASE WHEN datepart(m, Getdate()) > 3 THEN 4 ELSE - 8 END - DATEPART(M, GETDATE()), DATEADD(d, 1 - DATEPART(d, GETDATE()),
However although the date I am getting is 1st April it also includes hours, minutes and seconds - In some cases InvDate is like 2012-04-01 00:00:00.000 and if I am comparing this to above it is not going to include this date.
I guess I could subtract hours, minutes and nanoseconds in the same way as above but thought there might be an easier way.