Issue with format

sharon95
Member Posts: 183
I have this function
GetMonth(month : Text) ris : Text
ArrayMonth[1] := 'A';
ArrayMonth[2] := 'B';
ArrayMonth[3] := 'C';
ArrayMonth[4] := 'D';
ArrayMonth[5] := 'E';
ArrayMonth[6] := 'F';
ArrayMonth[7] := 'G';
ArrayMonth[8] := 'H';
ArrayMonth[9] := 'I';
ArrayMonth[10] := 'J';
ArrayMonth[11] := 'K';
ArrayMonth[12] := 'L';
IF month[1] = '0' THEN
i := FORMAT(month[2]);
ris := ArrayMonth[month];
the parameter of the function is a text. I have to transform this into an integer to search the array... can anyone help me? thanks
GetMonth(month : Text) ris : Text
ArrayMonth[1] := 'A';
ArrayMonth[2] := 'B';
ArrayMonth[3] := 'C';
ArrayMonth[4] := 'D';
ArrayMonth[5] := 'E';
ArrayMonth[6] := 'F';
ArrayMonth[7] := 'G';
ArrayMonth[8] := 'H';
ArrayMonth[9] := 'I';
ArrayMonth[10] := 'J';
ArrayMonth[11] := 'K';
ArrayMonth[12] := 'L';
IF month[1] = '0' THEN
i := FORMAT(month[2]);
ris := ArrayMonth[month];
the parameter of the function is a text. I have to transform this into an integer to search the array... can anyone help me? thanks
0
Best Answers
-
Try this...
GetMonth(month : Text) ris : Text IF NOT EVALUATE(MonthAsInt,month) THEN EXIT(''); IF MonthAsInt IN [1..12] THEN BEGIN ris :='?'; ris[1] := 64 + MonthAsInt; END;
... where MonthAsInt is a local variable of type Integer1 -
something like...
DayNumberAsText := FORMAT(DATE2DMY(TableFiscal.DOB,1)); IF STRLEN(DayNumberAsText) = 1 THEN DayNumberAsText := '0' + DayNumberAsText;
...there are alternative methods but the above should do fine.5
Answers
-
The above code looks odd - what is it exactly you want to achieve?0
-
I have to get a letter from a number... the problem is that the parameter is a text and it gives me an error beacuse it tries to assign a text to an integer...0
-
Try this...
GetMonth(month : Text) ris : Text IF NOT EVALUATE(MonthAsInt,month) THEN EXIT(''); IF MonthAsInt IN [1..12] THEN BEGIN ris :='?'; ris[1] := 64 + MonthAsInt; END;
... where MonthAsInt is a local variable of type Integer1 -
wooooooooooo!!! great!!! Thank you!!!
0 -
and similarly, if I have DATE2DMY(TableFiscal.DOB,1) that returns "3" and I want to print "03", how can I do this?0
-
something like...
DayNumberAsText := FORMAT(DATE2DMY(TableFiscal.DOB,1)); IF STRLEN(DayNumberAsText) = 1 THEN DayNumberAsText := '0' + DayNumberAsText;
...there are alternative methods but the above should do fine.5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions