Linked Questions
15 questions linked to/from MySQL "between" clause not inclusive?
35 votes
5 answers
128k views
MySQL - DATE_ADD month interval
I face a problem with the function DATE_ADD in MySQL. My request looks like this : SELECT * FROM mydb WHERE creationdate BETWEEN "2011-01-01" AND DATE_ADD("2011-01-01", INTERVAL 6 MONTH) GROUP BY ...
2 votes
4 answers
5k views
MySQL - BETWEEN will not select correct results
I am trying to select rows that are in between two dates. First, here is my data: punch_id eid time unixtime punch_type day date doy 135 2 12:53 1314723193 0 ...
0 votes
6 answers
2k views
Difference between "between fromdate and todate" & " date >= fromdate and date <= todate"
I have come across the following queries, but not sure if there is any difference between them, select * from table where date between fromdate and todate V/S select * from table where date >= ...
0 votes
1 answer
1k views
Display counts for missing dates in mysql query
After I run the following query: SELECT DATE_FORMAT( added_datetime, '%Y-%m-%d' ) AS date, SUM( gender = 'male' ) AS male, SUM( gender = 'female' ) AS female FROM social_user WHERE ...
1 vote
3 answers
2k views
MySQL How to select a date record between the min and max
Say I have four dates, for example: 1/1/2018 2/5/2018 4/8/2018 9/9/2018 I want to 'select' a date in between the min and max. Either the 2/5/2018 record or the 4/8/2018 record ONLY. I think I'm close,...
0 votes
2 answers
388 views
mysql BETWEEN is exclusive on right for characters?
Consider this table named easy_drinks, +------------------+ | drink_name | +------------------+ | Kiss on the Lips | | Hot Gold | | Lone Tree | | Greyhound | | Indian ...
2 votes
4 answers
495 views
How to store business time in database to be able search when it's open?
Lets say shop is working from 8:00 till 23:00 and we use time format. Then it's easy. Some kind of: where NOW() > start and NOW() < end But what if shop working until 1:00am next day? And now ...
0 votes
1 answer
725 views
Rails, ActiveRecord and date
Stupid question maybe, but it drive me insane right now. Why User.where(:created_at => 1.day.ago..Time.now).count (0.8ms) SELECT COUNT(*) FROM "users" WHERE ("users"."created_at" BETWEEN '...
1 vote
1 answer
656 views
SQL Server query to get values between fromdate and todate as well as fromdata, todate
SQL Server query to get values between (from date) to (to date) with from date and to date. I had tried select * from abc where 1 = 1 and entrydate between '"txt1.Text"' and '"txt2.Text"' I get ...
-1 votes
2 answers
460 views
Query between two dates with MySQL
I am trying to get all rows in a database which have been created between two dates inclusively. When I search for meetings in 2013-05-01 and todays date, I get no results but when I search without ...
0 votes
2 answers
211 views
MySQL SP: Get Records from the last 4 Months, Month and Year Given
I am creating a Stored Procedure to get all the records from the previous 4 months, given the month and year variables. The datetime format of etimestamp column is 12/30/2020 12:000:00 AM. If inMonth &...
0 votes
1 answer
127 views
Possible alternatives to a bunch of sub Queries [closed]
I am querying on date column in table 1 based on subqueries. Subquery 1 in where clause gets description from foreign key referred table and subquery 2 pulls in data by some other condition. So my ...
1 vote
2 answers
150 views
Look up a date between two database fields
Hi I have a piece of code which looks up a year between to fields in the database which are year_start & year_end. And here is my code. SELECT * from $tableName where '$year' BETWEEN ...
0 votes
2 answers
100 views
SELECT All Birthdays that span 2 years (2012-2013)
Just curious if someone can give me some guidance with this issue of finding birthdates with MySQL. I currently have a 'calendar' that is setup, it shows 1 month + 3 days before and 3 days after that ...
0 votes
3 answers
108 views
Search Through All Between Values SQL
I have data following data structure.. _ID _BEGIN _END 7003 99210 99217 7003 10225 10324 7003 ...