LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

i have a string month one character long (1234567890AB) that I want to convert into a decimal month (123456789,10,11,12)

Solved!
Go to solution

 i have a string month which is one character long (1234567890AB) that I want to convert into a decimal month (123456789,10,11,12)

0 Kudos
Message 1 of 9
(2,609 Views)

Did you look in the String palette at the conversion functions?

 

 

 

Is your 0 -> 10 a typo, or is it actually supposed to be that?

0 Kudos
Message 2 of 9
(2,605 Views)

There are two functions called Decimal String to Number and Hexadecimal String to Number (on Function -> String -> String/Number Conversion)

0 Kudos
Message 3 of 9
(2,601 Views)

1=Jan=1, 2=Feb=2, 3=...9=Sep=9, 0=Oct=10, A=Nov=11, B=Dec=12.

 

I can do it using "matching regular expression" vi but I'm wondering if there's an easier way.  The decimal and hex conversion will screw up at the 0 =10.

 

Thanks

0 Kudos
Message 4 of 9
(2,588 Views)
Solution
Accepted by topic author ahhah

I see two easy ways to do this.  After doing the hex to number conversion, you can do a case statement for the value.  For the default case, just pass though the value.  For case 0, pass out 10, for case 10, 11 (A, B) increment the value before passing it out.

 

The other option is have the data type for the hex conversion be an I32 and index an array.  The array will just be out of order [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12].

0 Kudos
Message 5 of 9
(2,580 Views)

Well, there's always the simple lookup method:

 

 

 

Should there another papal decree to change the calendar, then you'd have some problems. Until then, though, you're probably safe...

0 Kudos
Message 6 of 9
(2,578 Views)

You might want to make a 1-D array of those characters, and do a search 1-D array.  If you set up the 1-D array correctly, the returned index will be your month number.

0 Kudos
Message 7 of 9
(2,573 Views)

@ahhah wrote:

1=Jan=1, 2=Feb=2, 3=...9=Sep=9, 0=Oct=10, A=Nov=11, B=Dec=12.

 

I can do it using "matching regular expression" vi but I'm wondering if there's an easier way.  The decimal and hex conversion will screw up at the 0 =10.

 

Thanks


Time to break out a custom Strict Type Ring

Months.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(2,571 Views)

Thanks.  All great suggestions!Smiley Happy

0 Kudos
Message 9 of 9
(2,561 Views)