A Function inside a Loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cfmx2008
    New Member
    • Jan 2008
    • 36

    A Function inside a Loop

    Hi,
    I have a column in my table that data type is "char" some data are number and some are text, and no way I can separate them. I'm using it to write an excel sheet. Is there any function in ColdFusion that I can use that treat the numbers as numbers and text as text. May be a loop to go true the rows an where it's number apply the formula and where it's text just dump it on the excel sheet that I'm making. I'll appreciate your hint.:-)
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Use the isNumeric function to determine whether a string is a number.

    Comment

    • cfmx2008
      New Member
      • Jan 2008
      • 36

      #3
      Thank you for the reply acoder,

      When I use isnumeric then it replace my string by 0. Here is what I have in my SQL to retrieve the data:

      Select convert2, LeadInventory, (CASE WHEN convert2 ='n' THEN convert(int , firstDay) ELSE isNumeric(first day) END) as firstday

      from Mytable


      Sometimes the value in "firstday" column is a number and sometimes is an Excel formula. and IsNumeric function will replace 0 by my formula.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You're using isNumeric (which returns a boolean) as a MySQL function.

        I meant for you to use isNumeric as a function to determine whether the field was a number or not and then, depending on that, apply the formula or otherwise.

        Comment

        • cfmx2008
          New Member
          • Jan 2008
          • 36

          #5
          Thanks so much. I got it. you're great!

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You're welcome. Glad to hear that you got it working.

            Comment

            Working...