I have been wracking my brain for days..
How do you take a datetimepicker box value and convert the 24hr time format HH:mm:ss to complete total unit seconds?
Basically if the datetimepicker is set to 01:01:01 The answer I am looking for would be 3661
Thank you for any help and reply.
Try this:
Dim dt As DateTime = Now()
Dim d2 As DateTime = Now.Date
Dim ts As TimeSpan = dt.Subtract(d2)
Dim s As String = ts.TotalSeconds
Get time by using Now for dt.
Get only the date for d2 which renders the time 00:00:00.
Subtract the lesser and voila :)
Related
I have been trying t figure this out for the pas 6 hours. Can someone please help me.
I used this DateTime picker vue-ctk-date-time-picker
Link to gitRepo https://github.com/chronotruck/vue-ctk-date-time-picker
My startdate looks like this in my vue data start: moment().format("YYYY-MM-DD HH:mm")
example: 2020-06-28 19:30
Now the date picker works fine and starts at that date and time. Perfect!
I want to add a maxDate to the dateTimePicker so people cant select a date and time higher than the current date. So i made another property in data like this
maxDate: moment().format("YYYY-MM-DD HH:mm")
Which is again just the datetime now.
As soon as i add the prop :maxDate='maxdate' on the date picker it keeps the date but the time goes to 00:00
Does not matter what format i make it and also does not matter if i use moment or not. maxDate prop changes my start date time to 00:00 and maxdate to 00:00.
If i do minDate with the exact same props and data then minDate work as expected. Time is correct date is correct.
Switch it back to maxDate and BOOOM! freakin 00:00 again
What am i doing wrong?
So figured it out. Max date should just be the date in date format without time.
maxDate = moment().format("YYYY-MM-DD")
and not
maxDate = moment().format("YYYY-MM-DD HH:mm")
I have this string: 28 June 2018 (22:05)
How can I compare it with my current time and get the difference?
For example if actual time was 29/06/2018 (05:49)
The difference will be: 7 hours 44 minutes
So input: 28 June 2018 (22:05)
Output: 7 hours 44 minutes
The first thing you need to do, is convert the string to a valid DateTime instance.
If you know your dates will always be in this format, you can do the following...
Dim mydate = DateTime.ParseExact("28 June 2018 (22:05)", "dd MMMM yyyy (HH:mm)", CultureInfo.InvariantCulture)
https://msdn.microsoft.com/en-us/library/w2sa9yss(v=vs.110).aspx
Once you've parsed the string into a valid DateTime instance, you can use all the normal date functions to do the comparisons.
I would first get the difference in minutes, like so...
Dim diffminutes = DateDiff(DateInterval.Minute, mydate, Now)
Then create a timespan like this...
Dim mytimespan = TimeSpan.FromMinutes(diffminutes)
Finally display the difference in hours and minutes like this...
Response.Write(mytimespan.ToString("hh\:mm"))
I am trying to set up a query that pulls data from a date field. The date range (for example) that I need is from 3:40 PM of yesterday to today's date up to 3:40 PM. In other words my day does not star at midnight, so the function Date() can't cover it.
I have set up the query as follows:
Between #2/5/2018 3:40:00 PM# And #2/6/2018 3:39:59 PM#
in a field formatted for general Date (mm/dd/yyyy h:mm:ss AM or PM). With this I would have to change the query every day.
I would like to be able to use the function Date() & Date()-1 to replace today's date (Date()) and Yesterday (Date()-1). How can I do it?
I have also tried having two fields one for the Date (formatted as short date mm/dd/yyyy) when the order was entered, and the time the order was entered (formatted for general Date (mm/dd/yyyy h:mm:ss AM or PM). However when I use the function Date() on the date field and >#h:mm:ss# on the Time field the query yields 0 records.
You can do simple calculus with dates and times. Try the following:
Between Date() - 1 + #3:40:00 PM# And Date() + #3:39:59 PM#
I have some records in my database as below:
Note that the StartDateTime and EndDateTime are in 24 hours-system.
But when I display the datetime in my view, the time format is 12 hours-system as below:
From the html code, the value for "1st" End Date Time is correct, but in 12 hours-system:
The dates are used to calculate the amounts. This resulted in wrong number of hours calculated based on the kendoui datetimepicker. Can i know how to solve this?
Here is the JS:
$("#Payment_End_Date_" + count).kendoDateTimePicker({
format: "dd/MM/yyyy HH:mm",
timeFormat: "HH:mm",
interval: 60
});
Change format to
format: "dd/MM/yyyy H:mm",
I'm using TimeSpan function in VB.NET to get the total hours in a billing month.
I have 30 days in a billing month, so supposedly, I have 720 intervals. Using Timespan normally, I would get 696 intervals. But I add a day in my "todate" in order to get my correct total hours.
This is my code:
Dim TS As TimeSpan
Dim totalhours As Integer
Dim todate As DateTime = #11-30-2014#
Dim fromdate As DateTime = #11-01-2014#
TS = todate.AddDays(1).Subtract(fromdate)
totalhours = TS.TotalHours
However, I don't think that manipulating my input date (by adding a day) is the best practice. Is there any way to configure the timespan function to get the inclusive total hours?
That is because you did not supply the time range. The date alone will be 12AM for the time part.
Dim TS As TimeSpan
Dim totalhours As Integer
Dim todate As DateTime = #11-30-2014 11:59:59 PM#
Dim fromdate As DateTime = #11-01-2014#
TS = todate.Subtract(fromdate)
totalhours = TS.TotalHours
That will be 1 hours shy.
Dim TS As TimeSpan
Dim totalhours As Integer
Dim todate As DateTime = #12-01-2014#
Dim fromdate As DateTime = #11-01-2014#
TS = todate.Subtract(fromdate)
totalhours = TS.TotalHours
Will get the correct amount since it is inclusive of time between the two dates.