Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Help: SQL For Returning Data Between Dates
fabiocardoso
post Aug 14 2005, 10:10 AM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 25
Joined: 7-August 05
Member No.: 7,682



I have a data base that possesss a field BIRTH. How I make a research that returns me all the aniversariantes in definitive period? example: 01/02/2005 - 15/03/2005.
Go to the top of the page
 
+Quote Post
WeaponX
post Aug 14 2005, 05:29 PM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: Members
Posts: 1,086
Joined: 21-June 05
From: New York
Member No.: 6,440



I'm not very good at SQL but I think I found what you want. I remember reading about this when I was curious on how SQL works and found the a short tutorial at W3Schools.
Go to the top of the page
 
+Quote Post
Houdini
post Aug 14 2005, 06:05 PM
Post #3


Super Member
Group Icon

Group: Members
Posts: 572
Joined: 25-April 05
From: Nashville Tennessee
Member No.: 4,340



It would help if you at least showed us the database structure because fields are in tables and tables are in databases then you would know how to write a query to retrieve the table data (one particular field in this case) and after obtaining that data running a PHP script which would filter out the wanted or unwanted data here is and example of just a small table

CODE
CREATE TABLE `authors` (
 `aid` varchar(25) collate latin1_general_ci NOT NULL default '',
 `name` varchar(50) collate latin1_general_ci default NULL,
 `url` varchar(255) collate latin1_general_ci NOT NULL default '',
 `email` varchar(255) collate latin1_general_ci NOT NULL default '',
 `pwd` varchar(40) collate latin1_general_ci default NULL,
 `counter` int(11) NOT NULL default '0',
 `radminsuper` tinyint(1) NOT NULL default '1',
 `admlanguage` varchar(30) collate latin1_general_ci NOT NULL default '',
 PRIMARY KEY  (`aid`),
 KEY `aid` (`aid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;


As you can see above all in single quotes are fields within a table called authors so from the limited information you gave it would be almost impossible to help someone answer your question. cool.gif
Go to the top of the page
 
+Quote Post
jvizueta
post Sep 22 2005, 11:44 PM
Post #4


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 22
Joined: 13-September 05
Member No.: 8,434



QUOTE(fabiocardoso @ Aug 14 2005, 05:10 AM)
I have a data base that possesss a field BIRTH. How I make a research that returns me all the aniversariantes in definitive period? example: 01/02/2005 - 15/03/2005.
*



Try this:

Select * from orders Where orderdate >='19970805' and orderdate <
dateadd(dd,1,'19970805')

or this methods from sql:

DateTime
SamallDateTime
Go to the top of the page
 
+Quote Post
Houdini
post Oct 15 2005, 03:47 AM
Post #5


Super Member
Group Icon

Group: Members
Posts: 572
Joined: 25-April 05
From: Nashville Tennessee
Member No.: 4,340



Have you tried the below:
CODE
SELECT birth FROM "tablename" WHERE birth BETWEEN 2005/02/01 AND 2005/03/15


You will notice that I have rearranged the dates because MySQL expects the dates to be entered YYYY-MM-DD and from the post it look like you had expressed it as Feburary the first 2005 and March the 15th 2005.

So since that is how MySql stores dates as shown above then that would be how you have to query it to get the response you would want.

Also I used "tablename" since I have no clue as to what table the field birth would be in, but you should know what to substitute for it.
Go to the top of the page
 
+Quote Post
iGuest
post May 29 2008, 02:46 PM
Post #6


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



sql queries for retriving dates between the given dates from the same table
Help: SQL For Returning Data Between Dates

Sql queries for retriving dates between the given dates from the same table
For example
05/13/2008 to 05/26/2008
I want to retrive the dates from a tables between those days...

-reply by sujai
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



- Lo-Fi Version Time is now: 14th October 2008 - 03:31 AM