Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I add minutes to a specific time in c#.net?

Posted on 2008-10-15
2
Medium Priority
?
1,182 Views
Last Modified: 2013-12-17
I have a text box  that will populate with the current time when you click inside the text box example(6:40pm). I have another text box that users will enter just a number to represent minutes example (30). I have another text box that I want to display the time after adding the minutes entered to the current time.

EXAMPLE 6:40pm + 30 = 7:10pm
0
Comment
Question by:wademi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 22727146
Convert the value in the first textbox to DateTime object.
And then call the AddMinutes() method of that object with the data in the second textbox as argument.
0
 
LVL 6

Accepted Solution

by:
carlsiy earned 2000 total points
ID: 22727158
Provided that you have 3 TextBoxes.
textBox1 = Current Time
textBox2 = Amount of minutes to be added
textBox3 = Output of textBox1 + textBox2

        private void button4_Click(object sender, EventArgs e)
        {
            textBox3.Text = DateTime.Parse(textBox1.Text).AddMinutes(double.Parse(textBox2.Text)).ToShortTimeString();
        }
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question