dm0.pro1qry.sql.add('delete product1 where (day0 >= +'''+datetimepicker1.datetime+''') and (day0 <= +'''+datetimepicker2.datetime+''')');
這一句如何變化數據類型﹐day0是日期型字段﹐我想查找兩個日期之間的記錄﹐如何表達?
你參考一下:
其中使用的Cast與Substring函數主要是讓日期中的時間去掉。(a.CurDate為日期型字段)
S:=' select Count(*) from SchStatus a, Schedule b where a.Single_No=b.Single_No and b.Code_No='+''''+Code_No+''''+
' and a.Single_No<>'+''''+Query3.FieldByName('Single_No').AsString+''''+
' and a.Node in ("P","Q","R","S","T","U","V","X")';
S:=S+' and ((a.CurDate>Cast(substring('+''''+DatetimeToStr(DbDateTimePicker2.Date)+''''+',1,11) as datetime) and a.CurDate<Cast(substring('+''''+DatetimeToStr(DbDateTimePicker3.Date)+''''+
',1,11) as datetime)) or (a.CurDate=Cast(substring('+''''+DatetimeToStr(DbDateTimePicker2.Date)+''''+',1,11) as datetime) and a.Node>='+''''+copy(DBComboBox2.Text,1,1)+''''+
' ) or (a.CurDate=Cast(substring('+''''+DatetimeToStr(DbDateTimePicker3.Date)+''''+',1,11) as datetime) and a.Node<'+''''+copy(DBComboBox3.Text,1,1)+''''+'))';