help with date query

  • i have a table which has a date in called "Date", the dataType is set to date

    in this table i have three records at the moment, see below.

    ID Date Name

    1 2012-05-09 Test1

    2 2012-05-08 Test2

    3 2012-05-07 Test3

    when i run this query no results are shown, i really dont know why this is.

    SELECT id, Date

    FROM TblJobClock

    WHERE (Date = GETDATE())

    If someone could help me I would be very helpfull.

  • GETDATE() returns a datetime type that does include the time. Try this instead to get just the date:

    convert(date,GETDATE())

  • as mentioned above it has to do with the time portion.

    select convert(datetime,date), getDate() from TblJobClock to see the comparison you were attempting to make.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply