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'm using phpmyadmin to import a CSV file into a MySQL database, the file contains a column that has 672 binary numbers, if I import that without checking the box The first line of the file contains the table column names (if this is unchecked, the first line will become part of the data) everything goes in as VARCHAR columns and life is good.
If I check that box however, it tries to insert that column as a BIGINT and it fails because the maximum value for that is 255.
How can I modify the fields in the CSV file or while importing to MySQL to say consider every column is a varchar?
EDIT
Here's a subset of the data I'm trying to import. Save that into a CSV file:
ZomatoURL,PhoneNumber,More Info,Claimed,Booking,Hours2,RestaurantName,HoursMon,HoursTue,HoursWed,HoursThu,HoursFri,HoursSat,HoursSun
https://www.zomato.com/sydney/koi-dessert-bar-chippendale,02 9212 1230,More Info Takeaway Available Wheelchair Accessible No Alcohol Available Gluten Free Options Desserts and Bakes Kid Friendly Vegetarian Friendly,Report Error Claim this listing,,MonClosedTue10 AM to 10 PMWed10 AM to 10 PMThu10 AM to 10 PMFri10 AM to 10 PMSat10 AM to 10 PMSun10 AM to 10 PM,KOI Dessert Bar,000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000000000,000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000000000,000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000000000,000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000000000,000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000000000,000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111000
https://www.zomato.com/sydney/kobe-wagyu-yakiniku-cbd,02 9283 2268,More Info No Alcohol Available Sake Buffet,Claimed listing?,Table booking recommended,"Mon 12 Noon to 2:30 PM, 5:30 PM to 10:30 PM Tue 12 Noon to 2:30 PM, 5:30 PM to 10:30 PM Wed 12 Noon to 2:30 PM, 5:30 PM to 10:30 PM Thu 12 Noon to 2:30 PM, 5:30 PM to 10:30 PM Fri 12 Noon to 2:30 PM, 5 PM to 11:30 PM Sat 12 Noon to 11:30 PM Sun 12 Noon to 10:30 PM",Kobe Wagyu Yakiniku,000000000000000000000000000000000000000000000000111111111100000000000011111111111111111111000000,000000000000000000000000000000000000000000000001111111111000000000000111111111111111111110000000,000000000000000000000000000000000000000000000001111111111000000000000111111111111111111110000000,000000000000000000000000000000000000000000000001111111111000000000000111111111111111111110000000,000000000000000000000000000000000000000000000001111111111000000000011111111111111111111111111000,000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111000,111000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111110
https://www.zomato.com/sydney/home-thai-cbd,02 9261 5058,More Info Takeaway Available BYO BYOW Vegetarian Friendly,Report Error Claim this listing,,Mon 11 AM to 11 PM Tue 11 AM to 11 PM Wed 11 AM to 11 PM Thu 11 AM to 11 PM Fri 11 AM to 11 PM Sat 11 AM to 11 PM Sun 11 AM to 11 PM,Home Thai,000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111110000,000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000,000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000,000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000,000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000,000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000,100000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111
I am trying to create a weekly report (including grouping by WEEK(date)) where weeks start on Monday. However, Week 1 is always the first week any day of a new year occurs. For example if Jan 1st is a Friday, that is week one.
This doesn't seem to be consistent with MySQL mode options for WEEK():
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week
Based on the available options it only works if the week has 4 or more days (options 1 and 3) or the Monday is in the new year (options 5 and 7). Neither of these account for example week 1 of 2016:
Wk Mon Tue Wed Thu Fri Sat Sun
No.
1 28 29 30 31 1 2 3
Is there any way to order/number the week numbers in MySQL based on this custom week mode requirement?
If complaint filed on 5 pm on Saturday and closed on 1 pm on Monday, ticket should exclude sunday 24 hours.
Complaint Creation Date:24 Sept 2014, 6:00 PM Sat
Complaint Closed Date : 26 Sept 2014 ,6:00 PM Monday
Time taken :1 day not 2 day
Need Suggestions..
You can try somthing like this:-
SELECT CASE WHEN DAYNAME(DATE_ADD(Complaint_Creation_Date, INTERVAL 1 day)) = 'Sunday'
THEN (TIMESTAMPDIFF(HOUR,Complaint_Creation_Date,Complaint_Closed_Date))/24 - 1 AS "TIME TAKEN"
ELSE
(TIMESTAMPDIFF(HOUR,Complaint_Creation_Date,Complaint_Closed_Date))/24 AS "TIME TAKEN"
END
FROM YOUR_TABLE;
first of all i have a table like this:
userID Day Hour Class
---------------------------------------
65 Monday 08:00 Math
65 Monday 09:00 Bio
65 Monday 13:00 History
65 Tuesday 08:00 Sports
65 Friday 10:00 Math
I am choosing the classes according to the current time.
When it is 08:30 then i need to choose the next Hour which is 09:00 and it is Bio. And it is fine.
But when it is 10:00 then i need to choose 13:00 which is History.
Added: lets say today is Tuesday and it is 07:00 o'clock. With the code below , I can choose tne next coming Class whish is at 08:00 on Tuesday.
Lets assume today is Tuesday and 12:00 o'clock. How can I choose the next lecture which is on Friday (next weekday that I have a class on).
When I have no class in one day ,how can I choose the next avaible day that I have a class ...?
try something like this:
select `Hour`, Class
from your_table
where time(`Hour`) > curtime()
and `Day` = DAYNAME(now())
order by time(`Hour`) asc
limit 1