Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

TimeSpan is relative. You cannot "convert" it to date-time.

You can do something like this:
C#
DateTime.Now.AddTicks(TimeSpan.FromSeconds(0).Ticks)


Just add it to your relative date.
 
Share this answer
 
You can use a datetime object as base of calculations. For example

VB
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()
 
Share this answer
 
If I got you, you should choose the (say) updateStartTime (a DateTime) and then increment it using the updateInterval value.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900