Help: SQL For Returning Data Between Dates

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > SQL (Structured Query Language)

Help: SQL For Returning Data Between Dates

fabiocardoso
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.

Reply

WeaponX
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.

Reply

Houdini
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

 

 

 


Reply

jvizueta
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

Reply

Houdini
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.

Reply

iGuest
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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. get data between 2 dates in sql - 0.07 hr back. (1)
  2. sql between dates - 4.04 hr back. (1)
  3. between two dates get data sql query - 29.50 hr back. (1)
  4. sql command to find the greatest date between two dates - 30.71 hr back. (1)
  5. sql dates - 42.59 hr back. (1)
  6. between date sql 2005 example - 43.13 hr back. (1)
  7. sql 2005 date between - 45.05 hr back. (1)
  8. between dates and sql - 46.44 hr back. (1)
  9. sql between date examples - 46.83 hr back. (1)
  10. sql for finding data between dates - 46.96 hr back. (1)
  11. get data between to date mysql - 47.71 hr back. (1)
  12. sql 2005 between 2 dates - 50.14 hr back. (1)
  13. data between two dates in mysql - 50.79 hr back. (1)
  14. to get data from sql database between to dates - 51.45 hr back. (1)
Similar Topics

Keywords : sql returning data dates


    Looking for sql

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for sql
advertisement




Help: SQL For Returning Data Between Dates



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE