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

  • Home
  • SEARCH
  • 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 8200853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:35:43+00:00 2026-06-07T06:35:43+00:00

In SQL 2008 why do I get an error when I do this: select

  • 0

In SQL 2008 why do I get an error when I do this:

select datediff (minute, '23:30','24:00') 

The error is :

Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

Even if I were to change 24:00 to 00:00 why does the result say -1410?

What are the alternatives that I could use for this please?

  • 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-07T06:35:45+00:00Added an answer on June 7, 2026 at 6:35 am

    If you are looking for the difference between ’23:30′ and ’24:00′ – which technically is the next day, then you will use

    select datediff (minute, '2012-07-10 23:30','2012-07-11 00:00') 
    

    When you use:

    select datediff (minute, '23:30','00:00') 
    

    the ’00:00′ is being interpreted as the same day that is why you are getting -1410. There are a total of 1440 minutes in the day minus 30 minutes as the difference. The DATEDIFF function is:

    DATEDIFF ( datepart , startdate , enddate )
    

    If your end date ’00:00′ is before your start date then you will get a negative number.

    Edit:

    Based on your comment you will use the following for your table, then use a CASE statement around the endtime to add a day to it:

    select datediff(minute
                    , starttime
                    , case 
                    when endtime = '00:00' 
                    then dateadd(d, 1, endtime)
                    else endtime END)
    from yourtable
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

Using Sql Server 2008, developed a view vw_MasterView I get this error: Conversion failed
I'm trying to import IIS logs into SQL Server 2008. I get this error
How can I get a SQL dump of a SQL Server 2008 database? That
I want to get a field in SQL server 2008 from python 2.6. Here
In this live SQL Server 2008 (build 10.0.1600) database, there's an Events table, which
Hoping this is trivial for a SQL-Ninja... Been trying to get the following query
I’m trying to select various table and column names from a (SQL Server 2008)
I have this scenario: WServer 2008, SQL Server 2005, MS Analysis services (SSAS), ISS7
I can´t find an explanation to this behaviour (SQL Server 2008 + PHP 5.2.14)
I'm using SQL Server 2008 Express All of the select statments are fine. Now

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.