Hello,
Is there a function to convert a month name to its numeric value?
Ex. "March" would be 3.
Thanks,
Cory
Hello,
Is there a function to convert a month name to its numeric value?
Ex. "March" would be 3.
Thanks,
Cory
And how would you handle different languages?
But for starters you can solve it with a 1-liner:
cSearch = "march"
? ASCAN( aMonth, cSearch, 1, ALINES( aMonth, "January,February,March,April,May,June,July,August ,September,October,November,December", 1, ","),1,1)
wOOdy
If you want different languages I'd set up the data in a table with month name, in each language, then the month number and just look it up.
That way it is future proof as you can just add new entries and is much easier for teh end user to deal with as it is no longer hard coded.
Thank you for the replies and suggestions.
Cory
Woody,
I think you have too many parameters in the code. It crashed Lianja.
Separating the code, it all worked fine.
cSearch = "march"
declare (or dimension if preferred) aMonth[12]
?ALINES(aMonth, "January,February,March,April,May,June,July,August ,September,October,November,December" , 1, ",")
?ASCAN(aMonth, proper(cSearch), 1)
Result: 3
Thanks for the help.
Cory
Last edited by CGibson; 2014-03-25 at 08:46.
Hi Cory,
no, the main problem is, that Lianja's implementation of ASCAN is not (yet) on VFP9 level, where there is another parameter. That's also why you need the Proper in your code. I admit that I tested my sample only in VFP9, sorry for that.
wOOdy
Crashed Lianja? In what way?
Please submit a ticket for that so it gets fixed.
Lianja froze then a message box appeared indicating I needed to close the program.
This happened a second time when I tried it.
Ticket has been submitted, although now if I try it, I'm getting an error message returned "ARRAY name was expected" instead of a program crash.
I'm not sure why it's behaving differently.
I've tried a computer reboot and it's no longer crashing the program.
No worries, Woody.
You helped to point me in the right direction.
Cory
Bookmarks