473,382 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

less than equal to not working.

kamill
71
I need to generate a report (with fromdate and todate).If we set the “from” date and “to” dates as the same it should generates a report for that date.
If we set the “from” date as one day before the “to” date it generates a report for two days…..

And so on….

But i am unable to generate report for current date, less then equal to not working it treated as less then only.
my query is following.

Expand|Select|Wrap|Line Numbers
  1. SELECT `date_time` FROM `mydatatable` where `date_time` >= '$fromdate' AND `date_time` <= '$todate';
Aug 1 '07 #1
6 6270
dafodil
392 256MB
Check if the $todate has the same format as date_time and $fromdate
Aug 1 '07 #2
kamill
71
Check if the $todate has the same format as date_time and $fromdate
$todate and $fromdate both are same

suppose i want to access report of current date, my query is
Expand|Select|Wrap|Line Numbers
  1. select * from `mydatatable` where `date_time` >= '2007-08-01' and `date_time` <= '2007-08-01'; 
But this query not return any record, if i change to date by 2007-08-02, then it will return result for today date.
Aug 1 '07 #3
dafodil
392 256MB
$todate and $fromdate both are same

suppose i want to access report of current date, my query is
select * from `mydatatable` where `date_time` >= '2007-08-01' and `date_time` <= '2007-08-01';

But this query not return any record, if i change to date by 2007-08-02, then it will return result for today date.
Do you use timestamp for the dates? Maybe because you are using text. You should convert them to timestamp. and do not compare them to strings use numbers like '20070802000000'.
Aug 1 '07 #4
mwasif
802 Expert 512MB
Kinldy use appropriate code tags when posting code/syntax. Please follow this site's Posting Guidelines when posting questions or answers.
Aug 1 '07 #5
mwasif
802 Expert 512MB
Try this query
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `mydatatable` WHERE `date_time` >= '2007-08-01 00:00:00' AND `date_time` <= '2007-08-01 23:59:59';
Or you can use BETWEEN too
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `mydatatable` WHERE date_time BETWEEN  '2007-08-01 00:00:00' AND '2007-08-01 23:59:59';
I am assuming date_time data type is datetime or timestamp.
Aug 1 '07 #6
kamill
71
Try this query
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `mydatatable` WHERE `date_time` >= '2007-08-01 00:00:00' AND `date_time` <= '2007-08-01 23:59:59';
Or you can use BETWEEN too
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `mydatatable` WHERE date_time BETWEEN  '2007-08-01 00:00:00' AND '2007-08-01 23:59:59';
I am assuming date_time data type is datetime or timestamp.
Thank You mwasif, Now i am able to generate accurate reports.
Aug 2 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ridimz | last post by:
I have implemented a binary search tree and am interested in displaying all keys less than a certain value. I understand how to approach this task if the searchValue is equal to root.key()....
1
by: Propel Exacto | last post by:
Hey guys, I am using MySQL 4.0.18 and I have a field named "order_datetime" in which I store data in the format 20041001 23:00:00 (for example Oct 1, 2004 11pm) When I do a select statement...
4
by: Jeremy Howard | last post by:
Hello everyone, I'm not a database guru so I'm sorry if this is a dumb question but here it goes... I have this sql query that I'm trying to run against a table on a Sql 2k server: SELECT ...
3
by: nrhayyal | last post by:
Hi All, thanks for reading this post. just wanted to know about the ratio of threads and processors. i am working on c++ on AIX5.2 platform. my c++ program are multithreaded programs. In a...
15
by: Murt | last post by:
Hi, when writing equations in vb .net, how do you enter the signs "less than or equal to" etc. thanks Murt
26
by: Christoph Zwerschke | last post by:
You will often hear that for reasons of fault minimization, you should use a programming language with strict typing: http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html I...
10
by: gw7rib | last post by:
I have written a sorting program, to try to understand how heapsort works. Unfortunately, considering it's supposed to help my understanding, one line of it has got very ugly and so I was wondering...
16
by: Cory Nelson | last post by:
Does anyone know how std::set prevents duplicates using only std::less? I've tried looking through a couple of the STL implementations and their code is pretty unreadable (to allow for different...
12
by: DAHMB | last post by:
I am trying to the following but it stops priot to completion: ...... Case rs!Rank = "6" And Forms!frmOverTime!YearsInRank < 1 stRateOfPay = "Ptlm1" Case rs!Rank = "6" And...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.