Home > Back-end > How do you write this according to the date of the query parameterized queries?
How do you write this according to the date of the query parameterized queries?
Time:04-26
ADOQuery1. SQL. The Add (' Select * From Student ');//query students table ADOQuery1. SQL. The Add (' Where the Birthdate BETWEEN ' ' '+ DateToStr (DateTimePicker1. Date) +' 00:00:00 ' 'AND' ' '+ DateToStr (DateTimePicker2. Date) +' 23:59:59 '");//query in this range of date of birth ADOQuery1. Open;
CodePudding user response:
ADOQuery1. SQL. The Add (' Select * From Student ');//query students table ADOQuery1. SQL. The Add (' Where the Birthdate BETWEEN: vDate1 AND: vDate2 '); //DataType setting parameter type ADOQuery1. The Parameters. ParamByName (' vDate1). DataType:=TFieldType. FtDateTime; ADOQuery1. The Parameters. ParamByName (' vDate1). Value:=DateTimePicker1. Date; ADOQuery1. The Parameters. ParamByName (' vDate2). DataType:=TFieldType. FtDateTime; //IncDay is date plus one day ADOQuery1. The Parameters. ParamByName (' vDate2). Value:=IncDay (DateTimePicker2. Date);