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",
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 a dataset with column named "msg_dateStr" which contains user's accessing date and time.
I tried to split it into two different columns; date and time, and I did SELECT date(msg_dateStr, 'localtime') as Year
but it returns null straight.
I don't know why this happens and how I can make sure something went wrong.
Any advice will be appreciated.
The date to be used by the Date and Time Functions such as date MUST be in a format that is recognised by SQLite for a useful result. Recognised formats are (extract from the link above) :-
Time Strings
A time string can be in any of the following formats:
YYYY-MM-DD
YYYY-MM-DD HH:MM
YYYY-MM-DD HH:MM:SS
YYYY-MM-DD HH:MM:SS.SSS
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.SSS
HH:MM
HH:MM:SS
HH:MM:SS.SSS
now
DDDDDDDDDD
You need to ensure that the data is saved accordingly or alternately (but not recommended at all) reformat the column via SQL (e.g. using the substr built-in function).
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 want to format the dtime2 field in my query: SELECT FORMAT(MAX(dTime),'yyyy-MM-dd hh:mm:ss') FROM triangulations
This gives the output { result: [ { '': '03:34:30' } ], rowcount: 1 }
The hours should be 15. This is also displayed when leaving the format out of the query. Query: SELECT MAX(dTime) FROM triangulations gives output:
{ result: [ { '': Mon Jul 17 2017 15:34:30 GMT+0000 (Coordinated Universal Time) } ],
rowcount: 1 }
I execute the query in NodeJs with the library node-mssql-connector.
Why is SQL giving my the wrong hours?
In your format string, yyyy-MM-dd hh:mm:ss, hh means you want the hours in the 12-hour-cycle format, so 3 and 15 are always 3 (AM and PM). Use HH to get them in the 24-hour-cycle format:
yyyy-MM-dd HH:mm:ss
Relevant docs, scroll down to the list of format specifiers.
You should use HH instead of hh:
SELECT FORMAT(MAX(dTime),'yyyy-MM-dd HH:mm:ss') FROM triangulations
Usually when you get bad hours while the minutes and dates are fine, in means that you're using the wrong time zone. This could mean that either the time in a wrong time zone was written to the database, or you're getting the date from the database in some other time zone that you're expecting.
You should always be explicit about time zones when working with dates (which you don't seem to be doing here when while putting the dates into the database), and it makes things much easier if you're always saving dates in UTC (which seems to be the case for the dates that you're reading here).
In Node you can convert the dates using the Moment module - Moment Timezone in particular. See:
https://momentjs.com/timezone/
See this answer for some examples - it's about Mongo instead of SQL server but you can use exactly the same conversion here:
Mongoose saving and retrieving dates with UTC time, change to server timezone
I know this probably is considered a repeat question so I will apologize in advance, but I have looked at question after question and everyone says the "hh" will display a 12 hour format. I keep getting a 24 hour format as if I have "HH". What gives?
strTime = Date.Now.ToString("hhmmsstt")
HH is 24 hour format while hh is 12 hour one
https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
On this link you can check all the possible time formats, so you are interested about the following:
"h"
The hour, using a 12-hour clock from 1 to 12.
More information: The "h" Custom Format Specifier.
"hh"
The hour, using a 12-hour clock from 01 to 12.
More information: The "hh" Custom Format Specifier.
"H"
The hour, using a 24-hour clock from 0 to 23.
More information: The "H" Custom Format Specifier.
"HH"
The hour, using a 24-hour clock from 00 to 23.
More information: The "HH" Custom Format Specifier.
You can use it like this
strtime = Format(Now, "hh:mm tt")
You get an output like this
04:33 PM
If for something you dont want the 0 behind 4 you just take out one h
strtime = Format(Now, "h:mm tt")
You can try
strTime = Date.Now.ToLocalTime()
to get a local time.