1
How to convert dates into sweep for date? I’m having difficulties in performing searches between dates, due to this discrepancy in the database where I perform the query.
When I enter my line of code:
select *
from TAB_FATURAMENTO
where cd_cliente like '%'
and dt_item between '15/05/2017' and '31/05/2017';
The result of my search returns me values from dates prior to my range.
The column dt_item
is in varchar(10) and stores the values in the format dd/mm/yyyy
.
When I try to use the CAST
, I have the following error:
ISC ERROR CODE:335544334
ISC ERROR MESSAGE:
conversion error from string "22/07/2008"
STATEMENT:
TIBOInternalDataset: "<TApplication>.frmMain.dlgWisql.<TIBOQuery>.<TIBOInternalDataset>."
Statement: select *
from TAB_FATURAMENTO
where cd_cliente like '%'
and CAST(TAB_FATURAMENTO.dt_item as DATE) between '15/05/2017' and '31/05/2017';
This must also be converted
between '15/05/2017' and '31/05/2017';
, or put the dates in this format between20170515' and '20170531
;– Maurivan
select * from TAB_FATURAMENTO Where cd_client like '%' and cast(TAB_FATURAMENTO.dt_item as date) between cast('15/05/2017' as date) and cast('31/05/2017' as date); // Would that be it, @Maurivan? Or is there another way to do it?
– Tony Anderson
Yes, you can test with date or datetime types. Or you can convert this way too:
CONVERT(DATETIME, CONVERT(VARCHAR (10), '13/05/2017', 103))
.– Maurivan
@Maurivan: The database manager is FIREBIRD. I think there is no Convert() function in Firebird.
– José Diz
That’s right @Josédiz, in Firebird there is no function. So far I have not been able to solve this problem..
– Tony Anderson