Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reterive records between two dates using DateTimePicker?

Status
Not open for further replies.

ameen

Programmer
Jun 24, 2001
32
IN
Can any one give me the SQL statement using BETWEEN keyword with two dates. In the SQL Statement, the date range to be mentioned as a variable which should picked the date from DateTimePicker.


Ameen
 
What database are you using? The trick is the date format for the database. I'm not sure about others but for MSSQL you could do something like this:

myQuery.sql.add('select * from yourtable where');
myQuery.sql.add('datefield between '''+formatdatetime('mm/dd/yyyy',datepicker1.date)+'''');
myQuery.sql.add('and '+formatdatetime('mm/dd/yyyy',datepicker2.date)+'''');


Which /should/ yield a query something like
select * from yourtable where datefield between '05/01/2001' and '06/01/2001' TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top