How to convert dates into varchar to date in SQL `Firebird`?

Asked

Viewed 1,810 times

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 between 20170515' and '20170531;

  • 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?

  • 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)).

  • 1

    @Maurivan: The database manager is FIREBIRD. I think there is no Convert() function in Firebird.

  • That’s right @Josédiz, in Firebird there is no function. So far I have not been able to solve this problem..

1 answer

1

Put it like this select * from TAB_FATURAMENTO where cd_cliente like '%' and dt_item between **"15/05/2017"** and **"31/05/2017"**

with Double Quotes that goes I do so.

  • 1

    I had difficulties and found this in a forum between "15/05/2017" and "31/05/2017"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.