Solved

Adding minutes to a date

Posted on 2007-11-21
4
653 Views
Last Modified: 2008-02-01
I have the following date which I need to add a number of minutes to determine the end date, how do I achieve this
 

           _appointment.StartDate = CType(_appointment.StartDate.ToShortDateString & " " & umeStartTime.Text, Date)
           
0
Comment
Question by:rocky050371
  • 3
4 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 20328157
So you need to add minutes to _appointment.StartDate AFTER you've done the CType?  Or are you trying to add number of minutes in umeStartTime.Text to get your end time?
0
 
LVL 27

Accepted Solution

by:
VBRocks earned 500 total points
ID: 20328208
In VB.NET, just do this:

_appointment.StartDate = CType(_appointment.StartDate.ToShortDateString & " " & umeStartTime.Text, Date).AddMinutes(3)

0
 
LVL 27

Expert Comment

by:VBRocks
ID: 20328227
Or, if you are trying to achieve this:

_appointment.StartDate = CType(_appointment.StartDate.ToShortDateString & " " & umeStartTime.Text, Date)

_appointment.EndDate = CType(_appointment.StartDate.ToShortDateString & " " & umeStartTime.Text, Date).AddMinutes(3)

0
 
LVL 27

Expert Comment

by:VBRocks
ID: 20328469
Another older method of adding dates and times is the DateAdd method, here's an example of adding
3 minutes:

_appointment.StartDate = DateAdd(DateInterval.Minute, 3, _
   CType(_appointment.StartDate.ToShortDateString & " " & umeStartTime.Text, Date))

        MsgBox(_appointment.StartDate.ToString())



0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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