where datum=getdate() doesn't work?

Results 1 to 3 of 3

Thread: where datum=getdate() doesn't work?

  1. #1
    Join Date
    Dec 1969

    Default where datum=getdate() doesn't work?

    howdy,<BR><BR>I have a datetime type field called datum (that&#039;s dutch for date) and when I try to do an<BR><BR>select datum from table where datum=getdate()<BR><BR>i get 0 records returned, while<BR><BR>select datum from table where datum=&#039;"&date&"&#039;"<BR><BR>works fine.<BR><BR>what the problem with the code? the timestamp?<BR>and if so how can we ignore the timestamp?

  2. #2
    Join Date
    Dec 1969

    Default Read the documentation!

    GetDate() is a function that returns the current date...AND TIME...down to the second. (Or maybe it&#039;s millisecond?)<BR><BR>So how likely is it that you will have a record in your DB that has a "datum" field that matches the current date and time *to the second*???<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: where datum=getdate() doesn't work?

    Yep, the timestamp is the problem, GetDate also returns the exact time.<BR><BR>SELECT Datum FROM Table WHERE Convert(char(10),datum,105) = Convert(char(10),GetDate(),105)<BR><BR>This converts the date to a mm/dd/yyyy dateformat (without the time).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts