In MySQL I have data of date like this
Day-Month-Year H D time
12-01-2016 23:00
13-01-2016 00:00
Chart.js code of display date:
type: 'time',
time: {
displayFormats: {
hour: 'DD-MM-YYYY h:mm a'
Chart.js stops on 12-01-16 23:00
Next date is 13-01-16 00:00
Why Chart.js can't show this 13-01-16 00:00 no mater if I change it to 13-01-16 00:10
After 13-01-16 00:00 i have 10 hours to show on chart :/
I whant to display date like: DD-MM-YYY
In SQL date is 12-01-2016 23:00 [MM-DD-YYYY]
but Chart.js display : 01-12-2016 Like I whant
I intentionally insert date in MYSQL like 12-01-2016 23:00 [MM-DD-YYYY]
Chart.js
enter image description here
second .png excample is correct :)
Help
Related
Hello guys hope you're having a nice day.
What I'm trying to do is to get data from my db monthly. But what I want is to get data every day for example of all January:
DECLARE
#FromDate Datetime = Convert(datetime,'2022-01-01 12:00:01'),-- all January
#Datetime = Convert(datetime,'2022-01-31 17:00:00')
I have a table called Delivery_order_dtm which has the date and the time of item delivery.
I want every day the data between 12 :00:01 and 17:00:00 ONLY. so when the program finishes fetching data of 1-1-2022 between 12:00:01 and 17:00:00 I want it to go to 02-02-2022 and do the same thing between 12:00:01 and 17:00:00 then go to 03-03-2022 and so on.
Right now how I wrote it it is giving me all the data starting from 01-01-2022 12 PM and ending in 31-01-2022 5 PM that is not what I want.
I want everyday after fetching from 12 pm to 5 pm of this day to break and go to the next day from 12 pm to 5 pm.
Hope you can help me thank you!
I have a Stored Procedure which will be returning the columns Date( in yyyy/mm/DD HH:mm:ss format),Names and Data. When I'm making the Date part of Date(in MM/dd/yyyy format as parent row group ,Time part of Date as child row group and Name as column group and Data as the value in the matrix, I'm getting the time values consistently from 1:00 ,1:30,2:00,2:30 .. to 11:30 and it is displaying 23:59,12:00, 00:30 and jumping to the other Date group instead of staring from 00:30,01:00 ...to 11:30 and continuing as 12:00,12:30,13:00 to 23:59. The SP results will contain the time for one of the names from 00:30,01;00,01:30 to 23:30 and 23:59 and the other name will have times as 01:00,02:00 to 23:00 and 23:59.
I'm getting the values correctly up to only 11:30 starting from 01:00. I need the time values to be 00:30,01:00,01:30...12:00,12:30...23:00,23:59
Note:(since grouping is involved and one of the name's time does not equals other, 0 will be displayed in those cells - It is also working fine but only up to time 11:00 and it is displaying 23:59,12:00,00:30 and jumping to the other Date group
Can someone please help on this?
Thanks in advance.
It sounds like you are grouping for time in a 12-hour format but not including the period (AM/PM) which is tt in the formatting.
hh is for a 12 hour so you would need to add the tt
=FORMAT(Fields!DATE_FIELD, "hh:mm tt"
HH is for a 12 hour so you would not need to add the tt
=FORMAT(Fields!DATE_FIELD, "HH:mm"
The issue seems to be the type of grouping. I have used date for one of the groups and string type for other group. Now I have changed both to string and it is working fine.
My database collects data and stores in a database with date stamp (in fact two columns one date and another time. now my requirement is to have another column called date (just two digits of date ranging from 01 to 31) but the date should be changing at 06:00 hours instead of 00:00. so for example if date is 14th of Dec and time is 05:30, the DATE should return as 13 and should change to 14 only after 06:00 on 14th Dec. similarly if the date is 15th Dec and time is 03:00 , it should show 14 and not 15
please help in building a sql syntax to achieve the same.
Thanks in advance
Manjunath S
My table
starttime | endtime | id
10:30 11:30 1
11:30 12:30 2
14:30 16:30 3
15:30 16:30 4
I need to find the id in a given time slot for example
say
10:30 to 13:30 should give me o/p 1 2
11:30 to 16:30 should give o/p 2 3 4
The statement I am using
select id from table where STR_TO_DATE(starttime,'%h:%i')>='10:30' and STR_TO_DATE(endtime,'%h:%i')<='22:30';
it gives me only 1 and 2
I am not able to get the correct output what am I doing wrong here?
Note start and end time in varchar
EDIT-
If I wanted to selectthe id's between 10:30 to 12:30 I use this below command
select id from table where STR_TO_DATE(starttime,'%H:%i')>='10:30' and STR_TO_DATE(endtime,'%H:%i')<='12:30';
This gives me only id 1 .. but not giving me 2, If i change 12:30 to 12:40 it gives me 1 & 2.BUt I am using less or equal so it should give me both the id's right? Why its not working like that?
STR_TO_DATE(starttime,'%h:%i')
You are using the format %h which according to the documentation is for:
Hour (01..12)
Essentially, everything above 12 is invalid (Returns NULL).
And, you gave values above 12 to those ids.
Use the specifier
%H
for hours in the format 00 - 23
or the specifier
%k
for hours 0 - 23.
I am trying to display data associated with date. However in my case, I don't want the date to start at 00:00:00 and finishes at 23:59:59. Rather I want it to start at 16:00:00 and finishes at 06:00:00 the next day. In other words I want to create a custom time for date.
In the same time I want to GROUP_BY date.
For instance I have these values in the database:
want it to give me:
date: 2013-09-08 count: 2
date: 2013-09-09 count: 1
I am not asking for code, but a way to think about it, or useful methods.
Thank you in advance!
The simplest method is to take the existing date and subtract six hours to get the "effective" date. You would do this for output purposes only.
Example:
select date(datecol - interval 6 hour) as MyDate, count(*)
from t
group by date(datecol - interval 6 hour);
You can use a where clause to remove the times between 6:00 and 16:00 (unless that is a typo).