Timespan to display just the days, without hrs, min, and sec - vb.net

Timespan to display just the days, without hrs, min, and sec.
my time span is coming like 30.00:00:00 for 39 days. please help in vb.net code.

Here is the TimeSpan documentation on MSDN. Assuming you start with this:
' Define an interval of 3 days, 16+ hours.
Dim interval As New TimeSpan(3, 16, 42, 45, 750)
Console.WriteLine(interval.Days())
Console.WriteLine(interval.ToString("dddd"))
You have two options for displaying time in days. The first is:
Console.WriteLine(interval.Days())
or you can format your time in the ToString function:
Console.WriteLine(interval.ToString("dddd"))
You would need to add as many ds as you are expecting to display or you will get an error.

Related

Round to sequencial values with a variable number of hours - Kotlin

I need to solve this problem that I've been trying for a long time and nothing to achieve.
In my app, the user clicks a button that advances through a calendar day by day, but, I need to return in this method, the exact sequence of a certain value that is given in a certain number of n days and n hours.
I explain: the calendar is stopped on a day whose value is: 22 days and 3 hours (1), the user clicks to advance one day and the new value for that day is: 22 days and 10 hours (2) which are converted into hours to return a sequential integer each day ahead.
Thus, in the formula ((day * 24) + hours) / 24 we have:
((22*24)+ 3)/24 = 22,125(1)
((22*24)+21)/24 = 22,416(2)
rounding these values, we have the value for both days, it is both 22, but the value for the next day would have to be 23.
Look:
For the current day the calculated value is 22
for the next day, it is also 22, but must be 23 (sequencial value).
How do I solve this in kotlin?
Can anyone here help me?
Thanks in advance
[EDIT]
Maybe I can better explain the problem with this figure

Is there a way to take the output of a (HH24:MI:SS - HH24:MI:SS) and convert it to only minutes in oracle sql?

So i am putting the sql code in that i have shown below and my output that i get from the ProcessEnd minus ProcessStart is the duration time which comes out as "0 0:0:8.135". However, i need it to only show in terms of minutes, i don't want the hours or seconds, just the minutes the process runs.
TO_CHAR(rh.PROCESSSTART,'DD-MM-YYYY HH24:MI:SS') AS "PROCESSSTART",
TO_CHAR(rh.PROCESSEND,'DD-MM-YYYY HH24:MI:SS') AS "PROCESSEND",
(rh.PROCESSEND - rh.PROCESSSTART) AS "DURATION",
"0 0:0:8.135"
It looks that PROCESSEND and PROCESSSTART are DATEs.
If so, subtracting them results in number of days.
In order to get number of minutes, you'll have to multiply number of days by
24, as there are 24 hours in a day
60, as there are 60 minutes in an hour
so the final result would be
(rh.processend - rh.processstart) * 24 * 60 as number_of_minutes

Basic DateTime Algebra

How do i go about writing some basic algebra math in vb.net?
Example:
I need to schedule a process to run 60 days before start date of an object.
When my process runs I do:
Now(UTC) - StarDate(UTC) = days diff
If days diff less than 60, i run my process immediately.
If its over 60 days, i need to schedule my process to run again in 60 days.
So this leaves me with:
X - [daysDiff] = 60
I know how to solve this on paper but not in vb.net code.
Example:
X - 107 = 60
add 107 to each side, i have my # of days to add (107)
How do i accomplish this in VB.net?
If you want to know when to run it: if it's over 60 days, then subtract 60 from that value, that will tell you when when to check again.... so if you do the initial check and it comes back 61 days different, it's over 60, so you subtract 60, leaving 1. So now you know you need to schedule it in 1 day. If you do the initial check and it comes out 107, you subtract 60 and the result is 47... so you know in 47 days, you need to run it again as that will be 60 days out. It's two simple steps.

Subtract current track time from total track time

Hey all i have a song playing that displays the time like so:
0:00 / 4:47
The first time is the tracks current time.
The second is the total track time of that song playing.
I split it like so:
Dim tmpTimes As Array = lblSongTime.Text.Split("/")
So tmpTimes(0) gives me 0:00 and tmpTimes(1) gives me 4:47.
Now i tried to subtract the tmpTimes(1) from tmpTimes(0)
Debug.Print(CDbl(tmpTimes(1).replace(":", "") - tmpTimes(0).replace(":", "")))
and i get: 447.. 446... 445... etc
What kind of calulation do i need in order to return a decending count?
Example: 4:47...4:46.....4:45...etc using the current time tmpTimes(0)?
You need to split the text MM:SS into Minutes and Seconds, then convert that to total seconds (m * 60 + s). Then you can do the math on seconds. Then you will need to convert it back into Minutes and Seconds for display.
You may also be able to use the Timespan class to do this.
Solved:
Dim times As String() = lblSongTime.Text.Split("/"c)
Dim elapsedTime As TimeSpan = TimeSpan.ParseExact(times(0).Trim(), "m\:ss", Nothing)
Dim totalTime As TimeSpan = TimeSpan.ParseExact(times(1).Trim(), "m\:ss", Nothing)
Dim remainingTime As TimeSpan = totalTime - elapsedTime
Debug.WriteLine(remainingTime.ToString("m\:ss"))

need a help subtract DateTimePicker

I need to subtract DateTimePicker1 - DateTimePicker2
DateTimePicker1 get infornet from The man who ran the software
DateTimePicker2 get infornet from The man who ran the software
The Datetimekiper is like (HH:mm d/M/y)
the date is because its can take 4 days.
so the hour can be 72- 96
I just need the numbers of hours and minutes.
You need to be handling the DateTime value, not the control itself.
try something like this:
Dim x = DateTimePicker1.value - DateTimePicker2.value
and then this x will have the timespan, so you can get total hours like this:
Dim hours = x.TotalHours