Comparing dates

  • I have the following in my where clause

    WHERE

    R.ORIG_URN = C.URN AND

    r.S_TIME = g.Timestamp AND

    g.Timestamp = c.Day AND

    c.TAPETSID = g.UnitID

    Please direct your attention to "g.Timestamp = c.Day"

    The problem I am having is that c.Day is only in the format "MM/DD/YYYY" and g.Timestamp is "MM/DD/YYYY HH:MM:SS"

    How can I tell SQL to only compare the MM/DD/YYYY and ignore g.Timestamp's HH:MM:SS???

  • If you're on SQL 2008 (as per forum), convert/cast to DATE datatype.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • You can try to convert your timestamp field to MM/DD/YYYY field and then compare

    Example is Convert(date,CURRENT_TIMESTAMP,101) or Convert(varchar,CURRENT_TIMESTAMP,101)

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

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