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 488069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:40:10+00:00 2026-05-13T01:40:10+00:00

These two TimeSpan are stored in the Database with 24hr format. No date, only

  • 0

These two TimeSpan are stored in the Database with 24hr format. No date, only TimeSpan.

Dim r As TimeSpan
Dim tsStart As TimeSpan
Dim tsEnd As TimeSpan

'tsStard is 12:27:30 (pm) this happened first
'tsEnd is 00:10:25 (am) then this happened later

'You can't store 24:10:25 in the column type Time(7)

r = tsEnd.Subtract(tsStart)

‘the r = -12:17:05

Is there any TimeSpan method to get this right? Thank you.

  • 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-05-13T01:40:10+00:00Added an answer on May 13, 2026 at 1:40 am

    If you know that tsEnd always represents a later point in time than tsStart but your database doesn’t store the dates, you can solve this by adding 24 hours to the end when the end is less than the start (pardon the C# syntax):

    if (tsEnd < tsStart) {
        r = tsEnd.Add(new TimeSpan(24, 0, 0)).Subtract(tsStart);
    } else {
        r = tsEnd.Subtract(tsStart);
    }
    

    As jball noted in the comments, this assumes that tsEnd is never later by more than one day, though we have no way to determine otherwise.

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

Sidebar

Related Questions

These two methods exhibit repetition: public static Expression<Func<Foo, FooEditDto>> EditDtoSelector() { return f =>
These two may look like they have no correlation but bear with me! In
Consider these two function definitions: void foo() { } void foo(void) { } Is
Do these two keywords have exactly the same effect, or is there something I
Notice these two RedHat Linux system configuration settings: $ getconf GNU_LIBC_VERSION glibc 2.3.4 $
Are these two terms interchangeable?
Can these two SVN clients collaborate? I have my projects checked out with Tortoise,
How would you refactor these two classes to abstract out the similarities? An abstract
I have these two pieces of code, wich one is more readable? foreach decimal
I've recently created these two (unrelated) methods to replace lots of boiler-plate code in

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.