Skip to main content
Inspiring
April 29, 2015
Answered

Convert String Data

  • April 29, 2015
  • 1 reply
  • 1495 views

I am using the CF10 Report Builder.

I need to convert a 6 character string and compare it to a 20 character string.

Input = 201516 needs to be converted to 201508 and 201601. I am trying to handle the conversion in my query and not pass any records that I do not want to count to my report. IF the is a better way I am open to suggestions. Here is the code in my query that gives me a "Conversion failed when converting the varchar value 'E' to data type int'

WHERE name.soc_sec = transact.soc_sec
         AND name.soc_sec = prospect.soc_sec
         AND name.soc_sec = approg.soc_sec
         AND name.soc_sec = nmcrs.soc_sec
         AND name.soc_sec = transact.soc_sec
         AND transact.accept <> 'v'
         AND transact.tcodes = 'AW'
         AND name.last_name not like '%Teste%'
         AND prospect.term_int NOT BETWEEN LEFT(rpt_schy.sch_yr, 4) + '08' AND  LEFT(rpt_schy.sch_yr, 2) + RIGHT(rpt_schy.sch_yr,2)  + '01'
        

AND transact.sch_yr = rpt_schy.sch_yr

Any help would be greatly appreciated.

This topic has been closed for replies.
Correct answer EddieLotter

By process of elimination, if you remove the entire where clause from your query, do you still get the error?

Cheers

Eddie

1 reply

EddieLotter
Inspiring
April 30, 2015

What is the data type (in the schema) of the following fields?

prospect.term_int

rpt_schy.sch_yr

transact.sch_yr

Cheers

Eddie

Cozmo2Author
Inspiring
April 30, 2015

All have string data types

EddieLotter
EddieLotterCorrect answer
Inspiring
April 30, 2015

By process of elimination, if you remove the entire where clause from your query, do you still get the error?

Cheers

Eddie