SQLTeam.com | Weblogs | Forums

Query with GetDate Function issue


#1

Hi,

I am having problem with this query. Query1 with GetDate Function is not returning proper result. If i copy the exact time returned from these functions and run the Query2, it is giving proper result.
What can be the issue?

Query1:
SELECT V.Vehicle,DATEADD(minute,ISNULL(NULL, -30),GETDATE()), GETDATE() ,

  • FROM tbl_A as A
    Left outer join tbl_V as V on A.V1ID = V.V1ID WHERE
    AV1_DateTime BETWEEN DATEADD(minute, -30, GETDATE()) AND GETDATE()

Query2:
SELECT V.Veh, * FROM tbl_A as A
Left outer join tbl_V as V on A.V1ID = V.V1ID WHERE
AV1_DateTime BETWEEN '2015-09-24 16:06:22.040' AND '2015-09-24 16:53:24.040'

Thanks in Advance


#2

The BETWEEN in the 2nd query, does not looks like 30 mins apart. Maybe this is the cause ?