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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:04:50+00:00 2026-06-05T18:04:50+00:00

I have a sample date DateTime startDate = DateTime.Parse(2011-01-01 00:00:00); DateTime endDate = DateTime.Parse(2011-01-03

  • 0

I have a sample date

DateTime startDate = DateTime.Parse("2011-01-01 00:00:00");
DateTime endDate = DateTime.Parse("2011-01-03 01:01:03");

How can I get it to Elapsed time of 49:01:03? I can’t get any string format including days.

Currently I want to use that on DataGridView’s Columns.

Below is the sample code of it:

private void dataGridView1_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
{
    e.Column.CellTemplate.Style.FormatProvider = new DayToHour();
    //e.Column.CellTemplate.Style.Format = "";
}

But I can’t get it work :(.

Note: I don’t have any problem on subtracting the date and time. I’m asking about the format.

Closed: Just used wrapper class inheriting from IFormatProvider.

  • 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-05T18:04:52+00:00Added an answer on June 5, 2026 at 6:04 pm

    I think there might no such format available so you will have to get the value on these lines

    TimeSpan diff = endDate - startDate;
    String.Format("{0:00}hr {1:00}mn {2:00}sec",
                         Math.Truncate(diff.TotalHours),diff.Minutes,diff.Seconds);
    

    Also have a look at this Custom Format provider

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

Sidebar

Related Questions

I have a sample data like this ID DATE TIME STATUS --------------------------------------------- A 01-01-2000
I have date and time stored in my database as MySQL DATETIME datatype. While
Consider the following: temp <- array(sample(1:100,12), dim=c(365,12)) Depth <- as.vector(seq(1,12,by=1)) time <- seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
I used date(Y-m-d H:i:s); to get current date time format but the result doesn't
I have created a CPTTradingRangePlot using the up-to-date sample code as an example. The
Say I have the following simple java bean: class MyBean { private Date startDate;
How can I get the built-in date formatting working in my Cake app? Maybe
I have created a sample query in sql server to parse data from xml
I have a date string that is coming in as what I believe to
I have data in my database that looks like this: Date (DateTime) Type (varchar)

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.