s_hausen

asked on

# find not zero value from a number string

hi,

i have a situation here where i have strings in format like a,b and c:

a) 000000000001000000000000000000000000000001010000000000000000

b) 000400400040040004004000400400040040004004000400400040000000

c) 444444444444444444444444444444444444444444444444444444444444

also i've a start date, for eg: 02/15/2013. I wrote some code, but couldn't find a way to find how to get the position of a not zero value.

so in case of

<cfset strs = "000000000001000000000000000000000000000001010000000000000000" />

<cfset startDate = "02/15/2013" />

<cfloop from="1" to="#len(VARIABLES.strs)#" index="i">

code, which finds values greater than 0 and there place in string

<cfset getDates = "DateAdd('d', i, 'VARIABLES.startDate')" />

<cfif value greater than 0>

#DateFormat(VARIABLES.getDates, 'mm/dd/yyyy')#<br />

</cfif>

</cfloop>

so in case of

02/26/2013, 03/28/2013 and 03/30/2013.

any comments, feedback and suggestion would be deeply appreciated.

i have a situation here where i have strings in format like a,b and c:

a) 00000000000100000000000000

b) 00040040004004000400400040

c) 44444444444444444444444444

also i've a start date, for eg: 02/15/2013. I wrote some code, but couldn't find a way to find how to get the position of a not zero value.

so in case of

**situation a**.

<cfset strs = "0000000000010000000000000

<cfset startDate = "02/15/2013" />

<cfloop from="1" to="#len(VARIABLES.strs)#"

code, which finds values greater than 0 and there place in string

<cfset getDates = "DateAdd('d', i, 'VARIABLES.startDate')" />

<cfif value greater than 0>

#DateFormat(VARIABLES.getD

</cfif>

</cfloop>

so in case of

**situation a**the result would be:

02/26/2013, 03/28/2013 and 03/30/2013.

any comments, feedback and suggestion would be deeply appreciated.

ASKER CERTIFIED SOLUTION

membership

Create a free account to see this answer

Signing up is free and takes 30 seconds.

**No credit card required.**ASKER

looks like i got the solution.

<cfset strs = "020000000001000000000000000000000000000001010000000000000000" />

<cfset startDate = "#DateAdd('d', -1, "02/15/2013")#" />

<cfloop from="1" to="#len(VARIABLES.strs)#" index="i">

<cfset theletter = mid(strs,i,1)>

<cfset getDates = "#DateAdd('d', i, "#VARIABLES.startDate#")#" />

<cfif VARIABLES.theletter gt 0>

<cfoutput>

#DateFormat(VARIABLES.getDates, 'mm/dd/yyyy')#-#theletter#<br />

</cfoutput>

</cfif>

</cfloop>

<cfset strs = "0200000000010000000000000

<cfset startDate = "#DateAdd('d', -1, "02/15/2013")#" />

<cfloop from="1" to="#len(VARIABLES.strs)#"

<cfset theletter = mid(strs,i,1)>

<cfset getDates = "#DateAdd('d', i, "#VARIABLES.startDate#")#"

<cfif VARIABLES.theletter gt 0>

<cfoutput>

#DateFormat(VARIABLES.getD

</cfoutput>

</cfif>

</cfloop>

ASKER

this helped me, to find out the correct solution.

ASKER

the string is: 00000000000100000000000000

and date is: 02/15/2013

so basically the first 0 in the string is date: 02/15/2013, but i only need the dates of those values, which are not 0.

so in this case, there are three 1's in the string. so the dates would be 02/26/2013, 03/28/2013 and 03/30/2013.

hope it'll clear the question.