Nov 2, 2004 #1 ukleaf Programmer Mar 16, 2004 27 GB Hi all, is there an easy way in Crystal to extract a number from a string? Basiclly the number within the string will always be set out like this, String line then number amount - £100.00 - thanks.
Hi all, is there an easy way in Crystal to extract a number from a string? Basiclly the number within the string will always be set out like this, String line then number amount - £100.00 - thanks.
Nov 2, 2004 #2 lupins46 MIS Feb 19, 2004 2,509 GB Maybe. So is the pattern ALWAYS: xxxxxx...xxxx dash poundsign amount dash And can it be said that the xxxx..xxxx will NEVER contain a dash or a poundsign. Are the amounts ALWAYS positive? Upvote 0 Downvote
Maybe. So is the pattern ALWAYS: xxxxxx...xxxx dash poundsign amount dash And can it be said that the xxxx..xxxx will NEVER contain a dash or a poundsign. Are the amounts ALWAYS positive?
Nov 2, 2004 Thread starter #3 ukleaf Programmer Mar 16, 2004 27 GB Hi there, Yes the text will always be the same up to the - and the £, just the amounts will vary... there will also be a - after the amount too, e.g. XXXXXX XXXXXXX .... - £1000.00 - XXXXXX XXXXXXX .... - £23.00 - ... ... Thanks Upvote 0 Downvote
Hi there, Yes the text will always be the same up to the - and the £, just the amounts will vary... there will also be a - after the amount too, e.g. XXXXXX XXXXXXX .... - £1000.00 - XXXXXX XXXXXXX .... - £23.00 - ... ... Thanks
Nov 2, 2004 #4 lupins46 MIS Feb 19, 2004 2,509 GB Use this formula, modified with your own tabl/field names. numbervar vStart; numbervar vEnd; vstart:= instr({mytable.myfield},"£"); vend := instr(vstart,{mytable.myfield},"-"); mid({mytable.myfield},vstart,vend-vstart) Upvote 0 Downvote
Use this formula, modified with your own tabl/field names. numbervar vStart; numbervar vEnd; vstart:= instr({mytable.myfield},"£"); vend := instr(vstart,{mytable.myfield},"-"); mid({mytable.myfield},vstart,vend-vstart)
Nov 2, 2004 Thread starter #5 ukleaf Programmer Mar 16, 2004 27 GB Great, thanks very much. I'll give it a try and let you know. Thanks again. Upvote 0 Downvote
Nov 2, 2004 #6 bdreed35 Programmer Mar 2, 2003 1,549 US You could also use something like this if you want the "£" included: split({table.field},"-")[2] If you don't want the "£" included, this should work for you: val(split({table.field},"-")[2]) ~Brian Upvote 0 Downvote
You could also use something like this if you want the "£" included: split({table.field},"-")[2] If you don't want the "£" included, this should work for you: val(split({table.field},"-")[2]) ~Brian