Skip to main content
Inspiring
Apr 29, 2015 6:17 PM UTC
Answered

Convert String Data

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 is closed to new replies. Start a new post to keep the conversation going.
EddieLotter
EddieLotterCorrect answer
Inspiring
Apr 30, 2015 2:20 PM UTC

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

Cheers

Eddie

9 replies

EddieLotter
Inspiring
Apr 30, 2015 1:25 PM UTC

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

prospect.term_int

rpt_schy.sch_yr

transact.sch_yr

Cheers

Eddie

Translate
Cozmo2Author
Inspiring
Apr 30, 2015 1:44 PM UTC

All have string data types

Translate
EddieLotter
EddieLotterCorrect answer
Inspiring
Apr 30, 2015 2:20 PM UTC

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

Cheers

Eddie

Translate