473,321 Members | 1,916 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,321 software developers and data experts.

How to display records between start and end date (2 columns)

194 100+
Hi everybody,

I am trying to get the records from a mysql table where i have two column as start_date and end_date.

i want to display a record when its start date begins, for example if the start date is 10-05-2010 (date, month, year) and if the today date is 10-05-2010, then this record should start displaying until its end_date and stop displaying if end_date gone.

i have used some sql statements which not fulfilled my requirements.
first one:
Expand|Select|Wrap|Line Numbers
  1. $sqlSelect = "select * from items where start_date >= '$today' and end_date<='$today';
  2.  
second one:
Expand|Select|Wrap|Line Numbers
  1.  
  2. $sqlSelect = "select * from items where DATEDIFF(start_date, '$today') <= 0 AND DATEDIFF(end_date, '$today') >= 0 ;
  3.  
  4.  

where $today=date("Y-m-d")

im using php to achieve this. please help me. thanx
May 8 '10 #1
1 6299
mfaisalwarraich
194 100+
:). i think i was doing something wrong with the sql statement here is corrected statement which worked fine:

Expand|Select|Wrap|Line Numbers
  1. select * from items where start_date<='$today' and end_date>='$today' 
  2.  
May 8 '10 #2

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

Similar topics

3
by: David Kuhn | last post by:
I have a query with a date field criteria of: Between And When the query is run, I am asked for the Start date and then the End Date. So far, so good. The records returned are all those in...
3
by: Kai Zhang | last post by:
I am trying to display some database records in datagrid using dataset. the records need to be displayed are couple of thousands, but the records in database that the SQL query needs to exam are...
7
by: CheezIt2831 | last post by:
hello, I have 5 tables(Alpha, Bravo, Charlie, Service, Trans). What i am trying to do is be able to select a start date and ending date for a report and include fields from the 5 tables. this is my...
1
by: Del | last post by:
I have a parameter query that requires the user to enter a Start Date: and End Date: and pull data between that date range. I am currently using the following parameter; Select * From mytable...
0
by: =?Utf-8?B?QW5pdGhh?= | last post by:
Hi, Currently for Announcement library a custom column "publish start date" is added and under the search result webpart changed the xslt by filtering the result based on the publish start date...
6
by: techbytes | last post by:
I have a text box which has the value of week no. Depending on the value of week no,i have to display the start and end date of that week in another text box. How to do it in JavaScript
2
by: bytes access nubie | last post by:
When a query is run, i want a prompt displayed allowing the user to enter < DATE to find all records less than the specific date. e.g. < 1/1/2011. I know how to do that with a start date AND...
1
by: divya birla | last post by:
Posted - 03/29/2011 : 06:34:20 I have a table which contain Topic, Sequence number and no of turns. User input the Single Start date and on the basis of which series of start date and end...
1
by: Amar Agundu | last post by:
Hello, I am developing webapplication in JSP.I have a resultset fetched from database.This contains records with many columns but I want to display them on a page in a neat manner.What is best way to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.