Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  86] [ 3]  / answers: 1 / hits: 17397  / 11 Years ago, tue, june 18, 2013, 12:00:00

In my project , I am generating and storing the Bill (invoice).
The date of Bill is coming to the textbox from the javascript date picker(small pop-up calender) before saving.
The format of the date is : DD-MON-YYYY (18-JUN-2013).



I am using 'Text' data type for storing dates in MySql table.



I have done selecting of records(Previous Bills) from the table by given single date like. . .




$result = mysql_query(SELECT * FROM outward WHERE date='.$date.' ORDER BY billNo);




Now, what i want to do is:
To select records (Bills) between two dates.....




My exact Question is:
Is it possible to query mysql database with this settings or I have to make some changes to select records between 2 dates efficiently ?
How can i achieve this ?



P.s. - Is it effective to use

1. SELECT * FROM outward WHERE date BETWEEN ' . $from_date . ' AND ' . $to_date . ' ORDER by id DESC

Or

2. SELECT * FROM outward WHERE date > 15-JUN-2013 and date < 18-JUN-2013



More From » php

 Answers
23

You should use strtotime PHP function to convert string date to UNIX timestamp format and change MySQL data type for date field to TIMESTAMP.



Than you can do effective queries with > and <.


[#77556] Monday, June 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
xiomara

Total Points: 378
Total Questions: 90
Total Answers: 104

Location: Guernsey
Member since Thu, Oct 7, 2021
3 Years ago
;