?
Solved

Datediff issue with smalldatetime

Posted on 2012-03-16
1
Medium Priority
?
509 Views
Last Modified: 2012-03-16
I have folowing code:

    SELECT @daysAgo=DATEDIFF(dd,LDatum, @LDatum) from LeistungenListe 

Open in new window


In DB LDatum has value '2011-07-04 00:00:00' now when I specify in my application as a date '2011-07-04 01:00:00' it returns me 1 day.

However when I specify '2011-07-03 12:00:00' I get 0 days. So it seems that somehow time 00:00 is treated as 23:59.

Is it right behaviour? How I can fix this without easy + 1 :)
0
Comment
Question by:ser_berto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 27

Accepted Solution

by:
Chris Luttrell earned 2000 total points
ID: 37731222
Check that you are not having a problem with timezone changes from your application to the database.  When tested straight in the databases the DATEDIFF functions correctly with both your test cases.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question