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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:36:20+00:00 2026-05-24T17:36:20+00:00

I have a table which contains a two column( start_time and end_time ).I am

  • 0

I have a table which contains a two column(start_time and end_time).I am getting the information of start and end time from the user and adding it to the table.Once the user enters the next start and end time I have to compare it with the database.

Suppose in table one row has start time as 2011-08-10 16:00:00 and end time is 2011-08-10 16:30:00.
Suppose the user enter value 2011-08-10 16:05:00.000 (start_time) and 2011-08-10 16:25:00 (end_time) I am able to capture the by using

      String getConflictTimeInBetween = string.Format("select                           question_id,question_text from " + data_variables.RES_TXT_STRING_QUESTION_TABLE + " where start_time<='{0}' and end_time>='{1}'", start_full, end_full);//question_text='DFS'"2011-06-23 14:55);//
                        com = new SqlCommand(getConflictTimeInBetween, myConnection);
                        dr = com.ExecuteReader();

                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                //Assign to your textbox here   
                                conflictQuestionIdAtBetween = dr["question_id"].ToString();
                                conflictQuestionTextAtBetween=dr["question_text"].ToString();
                            }
                        }  

Here are some sample overlaps that I want to prevent

  1. start_time from 2011-08-10 15:55:00 and end_time 2011-08-10 16:05:00 (five minutes overlap with already existing data)

  2. start_time from 2011-08-10 16:25:00 and end_time 2011-08-10 17:00:00 (five minutes overlap with already existing data)

  3. start_time from 2011-08-10 15:00:00 and end_time 2011-08-10 17:00:00 (30 minutes overlap with already existing data)

Can anyone help me how to solve these three issues.

  • 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-24T17:36:21+00:00Added an answer on May 24, 2026 at 5:36 pm

    Since you seem to have the SQL part, here’s the algorithm that finds the overlap in ticks between the input time and the row time.

        public long GetTimeOverlap(long inputStart, long inputEnd)
        {
            // I assume you can get the data yourself so heres only the algorithm.
            long rowStart = new DateTime().Ticks, rowEnd = new DateTime().Ticks;
    
            if (inputStart < rowStart)
                if (inputEnd >= rowEnd)
                    // case 3
                    return rowEnd - rowStart;
                else if (inputEnd > rowStart)
                    // case 1
                    return inputEnd - rowStart;
                // Input time is before row time.
                else return 0;
            else if (inputStart >= rowEnd)
                // Input time is after row time.
                return 0;
            else if (inputEnd >= rowEnd)
                // case 2
                return rowEnd - inputStart;
                // case 0
            else return inputEnd - inputStart;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings friends, In my MySQL database, I have 'MAB' table which contains information about
I have a table which contains chronological events. They have a type, time and
I have a table which contains chronological events. They have a type, time and
I have two tables - `employee` and `department`. 1. `employee` table contains column id,employee
I have a table with two columns. The first (which contains a menu) should
I have a situation where i have Keyword column in table which contains comma
I have a table which contains two type of data, either for Company or
I have a user table from which I want all values, so I have
I have a table which contains my server status create table ServerStatus ( ServerId
I have a table which contains my ads that can be searched in sql-server-2008.

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.