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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:11:34+00:00 2026-06-08T17:11:34+00:00

I encountered a problem that I can’t manage to save Excel start time and

  • 0

I encountered a problem that I can’t manage to save Excel start time and end time into the data base. For Excel, the time is as type, “String” but for the data base, it’s in type, “Time”. Is there any way that I could save the Excel Time into data base.

Here is my codes that save the data into data base but it only save the Name and Date but not the timings. Any help will be appreciated.

private void btnSave_Click(object sender, EventArgs e)
    {
        try
        {

            foreach (DataRow dr in dt.Rows)
            {
                string strEmployee = dr["Employee Name"].ToString();
                //store data into employeeshift DB
                using (satsEntities db = new satsEntities())
                {
                    ufi empShift;
                    IList<employeeschedule> employeeList = dict[strEmployee];

                    foreach (employeeschedule es in employeeList)
                    {
                        empShift = new ufi();
                        TimeSpan a = new TimeSpan(Convert.ToInt32(es.startTime.Substring(0,2), Convert.ToInt32(es.startTime.Substring(2,2))));
                        TimeSpan b = new TimeSpan(Convert.ToInt32(es.endTime.Substring(0,2), Convert.ToInt32(es.endTime.Substring(2,2))));
                        empShift.UFISDate = es.day;
                        empShift.EmployeeName = strEmployee;
                        empShift.startTime = a;
                        empShift.endTime = b;
                        db.ufis.AddObject(empShift);
                    }
                    db.SaveChanges();
                }
            }
            MessageBox.Show("Data is stored to database successfully.");
        }
        catch (Exception ex)
        {
            //showMessage("UNABLE to store to database successfully.");
            //show error
        }
    }

I can’t post my own answer due to my low reputation. After all, this is my answer that get my code working.

 private void btnSave_Click(object sender, EventArgs e)
    {
            foreach (DataRow dr in dt.Rows)
            {
                string strEmployee = dr["Employee Name"].ToString();
                //store data into employeeshift DB
                using (satsEntities db = new satsEntities())
                {
                    ufi empShift;
                    IList<employeeschedule> employeeList = dict[strEmployee];

                    foreach (employeeschedule es in employeeList)
                    {
                        empShift = new ufi();
                        TimeSpan a = new TimeSpan(Convert.ToInt32(es.startTime.Substring(0,2)), Convert.ToInt32(es.startTime.Substring(2,2)), 0);
                        TimeSpan b = new TimeSpan(Convert.ToInt32(es.endTime.Substring(0,2)), Convert.ToInt32(es.endTime.Substring(2,2)), 0);
                        empShift.UFISDate = es.day;
                        empShift.EmployeeName = strEmployee;
                        empShift.startTime = a;
                        empShift.endTime = b;
                        db.ufis.AddObject(empShift);
                        db.SaveChanges();
                    }

                }
            }
            MessageBox.Show("Data is stored to database successfully.");
    }
  • 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-08T17:11:35+00:00Added an answer on June 8, 2026 at 5:11 pm

    will this help

            string test = "1234";
            string startTime = test.Substring(0, 2);
            string Endtime = test.Substring(test.Length - 2);
            string NewTime = startTime + ":" + Endtime;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered a problem that took me too much time, but without resolving it.soI
I encountered a strange problem this week that I can't explain: I switched my
I encountered a problem that I can't solve. My point is to click my
When I write a C program, I encountered a problem that is as follows:
I'm currently exploring powershell capabilities, but I have encountered a problem that I have
I have encountered a most annoying problem that occurs on the PWD variable when
I have the following problem that other people must have encountered. I am working
I encountered a problem. I noticed that a Property (say MyProp ) in my
I have encountered a problem in my application. I have two forms, one that
I'm building a REST API, but I've encountered a problem. It seems that accepted

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.