Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:05:53+00:00 2026-06-01T16:05:53+00:00

I am using SQL Server and just identify one problem in my case. I

  • 0

I am using SQL Server and just identify one problem in my case.
I have used the DATEDIFF function as:

select datediff(dd,'1935-12-07','2010-03-02')/365.00  ---> 74.28
select datediff(dd,'1935-12-07','2010-03-02')/365     ---> 74
select datediff(yy,'1935-12-07','2010-03-02')         ---> 75

If you can observe that If I try DATEDIFF with ‘dd’ then I get the difference as 74/74.28.
But If I use it with ‘yy’ I get the diference as 75.

Why this is so? Means Why the difference came as 75 as it nearly approximate to 74.

I need this both function in different cases. But as it is behaving differently I am facing a lot of problems.

Suggest me some solution to this.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:05:54+00:00Added an answer on June 1, 2026 at 4:05 pm

    First case = You’re implicitly casting to a float, shows the correct result

    Second case = You’re implictly casting to an int, which rounds down as part of the conversion (Floor value)

    Third case = You’re not casting anything at all, and DATEDIFF() returns a signed int, which rounds up (Ceiling value)

    Solution: Do whatever you want, but keep it consistent throughout your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008 Management studio viewing a 2005 server and have just
I have just been told to get looking into using SQL server reporting. Does
I am using sql server 2005. I just want to know is there something
I've just installed SQL Server 2008 Developer edition and I'm trying to connect using
[using SQL Server 2005] I have a table full of users, I want to
I have just moved one of my projects into VS2010/fx4.0 and am using a
I'm using SQL Server 2008. Here is what I'm trying to do. I have
I have a SQL Server report project in VS 2005 that won't preview one
using SQL Server 2005 standard edition with SP2 I need to design a table
Using SQL Server, how do I split a string so I can access item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.