Click here to Skip to main content
11,647,170 members (70,914 online)
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)

  Print Answers RSS
0 jyo.net 510
1 OriginalGriff 352
2 DamithSL 310
3 Sergey Alexandrovich Kryukov 305
4 F-ES Sitecore 244
0 OriginalGriff 1,277
1 jyo.net 994
2 DamithSL 946
3 Sergey Alexandrovich Kryukov 853
4 CPallini 760


Advertise | Privacy | Mobile
Web01 | 2.8.150804.2 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2015
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