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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ado sql date search syntax help 1

Status
Not open for further replies.

DK47

Programmer
Jun 3, 2003
118
0
0
US
I need some help with the syntax required to return data between user specified dates.
txtFrom and txtTo are user input text boxes where only date formats are allowed.


adoChart.RecordSource = "SELECT * FROM History WHERE (Date) BETWEEN ' & txtFrom & ' AND ' & txtTo & ' AND Investor_Number = " & frmStartPage.txtHoldInvestorNumber & " Order By Date DESC"
adoChart.Refresh


Thanks,
Dwight
 
Try this

adoChart.RecordSource = "SELECT * FROM History WHERE (Date) BETWEEN ' & CDate(txtFrom) & ' AND ' & CDate(txtTo) & ' AND Investor_Number = " & frmStartPage.txtHoldInvestorNumber & " Order By Date DESC"

OR

adoChart.RecordSource = &quot;SELECT * FROM History WHERE (Date) => '&quot; & CDate(txtFrom) & &quot;' AND (Date)=<'&quot; & CDate(txtTo) & &quot;' AND Investor_Number = &quot; & frmStartPage.txtHoldInvestorNumber & &quot; Order By Date DESC&quot;
 
zarkon4,
Thank you very much for your time and your help.
Much appreciated!
Regards,
Dwight



I tried this with single quotes (') and double quotes (&quot;) as shown below and I still get sytax error (Missing operator)
Any other ideas?

adoChart.RecordSource = &quot;SELECT * FROM History WHERE (Date) BETWEEN &quot; & CDate(txtFrom) & &quot; AND &quot; & CDate(txtTo) & &quot; AND Investor_Number = &quot; & frmStartPage.txtHoldInvestorNumber & &quot; Order By Date DESC&quot;


I'll try your second example next.
DK
 


Make sure the quotes are correct

adoChart.RecordSource = &quot;SELECT * FROM History WHERE (Date) BETWEEN ' &quot; & CDate(txtFrom) & &quot; ' AND ' &quot; & CDate(txtTo) & &quot; ' AND Investor_Number = &quot; & frmStartPage.txtHoldInvestorNumber & &quot; Order By Date DESC&quot;

remove the spaces between the single and double quotes
 
Thanks, I'll give it a try.
DK
 
Shouldn't (Date) read [Date]?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Try this #

strsql = &quot;Select * from timedata where weekending BETWEEN #&quot; & datBegDate & &quot;# AND #&quot; & datEndDate & &quot;#&quot;
 
Jim and John,
Thanks guys.
DK
 
Jimgary,
Thanks buddy, your's did the trick.
Have great weekend.

Here's a star!

Regards,
Dwight
 
It would have been a lot easier if we had known that you were using a Jet db!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Sorry about that,
I'll be more detailed the next time.
Regards,
Dwight

PS
By the way I needed that bit of code to grab data for an MSChart control, and it works great.
Can't thank you guys enough for taking the time to help.
DK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top