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!

Filter a date from and through

Status
Not open for further replies.

heydyrtt

Programmer
Dec 12, 2001
63
US
Hello;

Have a table with a field called date_mail, on my form I have two datetimepickers one is named fromdate and the other todate. On exit of todate I want it show in the grid the data of the dates that were choosen. I can do this with codebase, but I'm changing over to SQL99 and having problems getting it to SQL format. Any help would be appreciated, below is the codebase code.

FilterStr = "";
DM->tblResident->Filtered = true;
FilterStr = "(DTOS(DATE_MAIL) >= '" + DTOS(fromdate->Date) + "') .AND. " +
&quot;(DTOS(DATE_MAIL) <= '&quot; + DTOS(todate->Date) + &quot;')&quot;;
if(jFilter.IsEmpty() == false && FilterStr.Length() < 60) {
if(jFilter.Pos(&quot;.AND.&quot;) == true) {
DM->tblResident->Filter = FilterStr + jFilter;
}
else {
DM->tblResident->Filter = FilterStr + &quot; .AND. &quot; + jFilter;
}
}
else {
DM->tblResident->Filter = FilterStr;


Thanks

heydyrtt
 
I figured it out here it is if anyone needs it. This is for a flashfiler database.

TDateTime BeginDt,EndDt;
String BeginStr,EndStr;

BeginDt = fromdate->Date;
EndDt = todate->Date;
BeginStr = BeginDt.FormatString(&quot;yyyy-mm-dd&quot;);
BeginStr += &quot; 00:00:00&quot;;
EndStr = EndDt.FormatString(&quot;yyyy-mm-dd&quot;);
EndStr += &quot; 00:00:00&quot;;

DM->ReasonQuery->SQL->Clear();
DM->ReasonQuery->SQL->Add(&quot;SELECT date_mail,res_lname,res_fname,reason&quot;);
DM->ReasonQuery->SQL->Add(&quot; FROM resident &quot;);
DM->ReasonQuery->SQL->Add(&quot;WHERE date_mail&quot;);
DM->ReasonQuery->SQL->Add(&quot; >= timestamp '&quot;+BeginStr+&quot;' AND &quot;);
DM->ReasonQuery->SQL->Add(&quot;date_mail <= timestamp '&quot;+EndStr+&quot;'&quot;);
DM->ReasonQuery->SQL->Add(&quot; ORDER BY date_mail&quot;);
DM->ReasonQuery->Open();
DM->ReasonQuery->Close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top