Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to know how can I add the time in one datetime variable to a date in another datetime variable.

 

dim startDate as DateTime
dim StartTime as DateTime

startDate = startDate + StartTime

 

I would appreciate any ideas as how to do that.

 

Thanks in advanced

You're either a one or a zero. Alive or dead.
  • *Experts*
Posted

Here is an example:

Dim dstart As DateTime = DateTime.Now 'set start as now
Dim dnext As DateTime = DateTime.Now.Add(New TimeSpan(1, 0, 0, 0))
'set next date as now plus 1 day
MessageBox.Show(dstart.Add(New TimeSpan(dnext.Ticks)).ToString)
'show the date that resulted in adding the start date plus the next date
'using the TimeSpan object and Ticks property  of the next date

:)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...