Date math in SQL

Results 1 to 2 of 2

Thread: Date math in SQL

  1. #1
    Ben Roy Guest

    Default Date math in SQL

    End and Start being smalldatetime fields, I want this:<BR><BR>SELECT Sum(([End]-[Start])*24) AS Hours<BR><BR>This worked fine in access and does NOT work in SQL. How do I make this work?<BR><BR>PS I&#039;d recommend against using End as a field name. It&#039;s not an access keyword, but IS a SQL keyword, which means you&#039;ll always need [] around it.<BR>

  2. #2
    Jeremy_D Guest

    Default RE: Date math in SQL

    SELECT Sum(DateDiff(hour, [Start], [End])) AS Hours FROM ...

Posting Permissions

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