SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast drorit30's Avatar
    Join Date
    May 2003
    tel aviv
    0 Post(s)
    0 Thread(s)

    usage of DateValue in SQL server

    Hi all,

    I have the following SQL statement which works on ACCESS but does not work in SQL server

    SELECT * FROM [table_name] where DateValue(Now()) < table_name.required_date

    required_date is a 'timedate' field which has both the date and the time.

    I need the sql statment to check only the date part of the field.

    SQL server does not allow the usage of DateValue like access does.

    What is the correct SQL statement which will perform this?

    Thank in advance,

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Toronto, Canada
    63 Post(s)
    3 Thread(s)
    dror, are you going to ask us every time your query does not work the same way in sql server as it used to in access?

    i think it's time you started looking these things up yourself in the sql server manual

    here's one page that will help you when the time comes to display a datetime value in a particular format --

    as for this specific "DateValue" problem, if you want rows of the table for a given date, you should select a range of datetime values like this --
    where table_name.required_date >= getdate()
       and table_name.required_date < dateadd(day,1,getdate()) | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Posting Permissions

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