Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating a decimal point?

Status
Not open for further replies.

kelani

MIS
Nov 29, 2000
44
US
I have a simple problem (for once)

Assume I have a version number, say

8.2.1010

and I want every reload of a page to update it like this

8.2.1011
8.2.1012
8.2.1013

but never go to 8.3 or so on.

My current query:

<CFQUERY name=&quot;logplus&quot; datasource=&quot;dbname&quot; username=&quot;usname&quot; password=&quot;pswd&quot; dbserver=&quot;localhost&quot; dbname=&quot;dbname&quot;>
UPDATE stats SET lobdv=lobdv+0.0001
</CFQUERY>

kills the .2 but updates the 0101 fine. Problem is, when it gets to 9999, it goes up to 9.0000, which isn't cool. I've tried

UPDATE stats SET lobdv=lobdv+0.0.0001

but that doesn't work.

Stupid, I know, but it's annoying :)

I promise, once I get these minor issues ut of the way I'll start posting many of my fixes to help out. I promise!

Kelani
 
I think the reason why this is happening is that you cannot add 0.0001 to 8.2.1011 as 8.2.1011 IS NOT A VALID NUMBER.

If you have these numbers stored in a database, I would store the three numbers 8, 2, 1011 in three separate fields and create a custom tag to handle the updating of these numbers (you will have to test the third number being 9999 and so update to 0000 and then update the second number,...)
Simon
 
Simon's right but I think this might work for you assuming lobdv is a text field.

<CFQUERY name=&quot;getCount&quot; datasource=&quot;dbname&quot; username=&quot;usname&quot;
password=&quot;pswd&quot; dbserver=&quot;localhost&quot; dbname=&quot;dbname&quot;>

select lobdv as num from stats

</CFQUERY>

<cfset newNum = listsetat(getCount.num,3,listgetat(getCount.num,3,&quot;.&quot;)+1,&quot;.&quot;)>

<CFQUERY name=&quot;logplus&quot; datasource=&quot;dbname&quot; username=&quot;usname&quot;
password=&quot;pswd&quot; dbserver=&quot;localhost&quot; dbname=&quot;dbname&quot;>

UPDATE stats SET lobdv=#newNum#

</CFQUERY>

I didn't test it so let me know if it doesn't work quite right.
GJ
 
Great suggestion GunJack, but you still have the problem when the current &quot;number&quot; ends with 9999 .........
Simon
 
Good point. If he doesn't want it to update the middle .2. then this should reset the count back to &quot;.0000&quot;.

<cfset newNum= .....>

<cfif len(listgetat(newNum,3,&quot;.&quot;)) gt 4>
<cfset newNum = listsetat(newNum,3,0,&quot;.&quot;)>
</cfif>

<CFQUERY .....
UPDATE stats SET lobdv=#newNum#

If he wants the last number to have leading zeros (hopefully not) then there's some additional string manipulation required.

GJ
 
Basically, it's lke a version number, with minor versions. I have control over the 8.x as those are major revisions, but each login sets off a series of changes that rightfully deserve a version increase :)

Along those lines, what's the parameter for showing the last update date/time for a database table?

Allaire sure has a lot of cool stuff, just nothing I need. Or maybe I'm weird :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top