Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I have developed a application
which performs certain tasks
based on time interval
set in app.config file
which is a XML file.
the time interval is in
timespan structure
as
<service updateInterval="0.00:02:00" />
 
I want to convert this value to a particular
time as 10am or any particular time.
How can I do this.
Please assist
any idea.
Posted 4-Oct-12 1:52am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

TimeSpan is relative. You cannot "convert" it to date-time.
 
You can do something like this:
DateTime.Now.AddTicks(TimeSpan.FromSeconds(0).Ticks)
 
Just add it to your relative date.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can use a datetime object as base of calculations. For example
 
    Dim dt As DateTime = New DateTime(2012, 10, 4, 0, 0, 0)
    Dim sp As TimeSpan = New TimeSpan(5000)
    Dim ts As String = (dt + sp).ToShortTimeString()
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

If I got you, you should choose the (say) updateStartTime (a DateTime) and then increment it using the updateInterval value.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100