Dataport: Importing text field to date field in table.
Aravindh_Navision
Member Posts: 258
Hi,
I have a requirement to import data from text files of fixed length to table. When I try to import the text (for date) field to date field in the table, I am unable to do it.
My requirement is how to convert the text field to date field and store in the table? I have searched in the forum, but I could not able to fine the solution.
Can anyone help me in achieving this?
Thanks,
Aravindh.
I have a requirement to import data from text files of fixed length to table. When I try to import the text (for date) field to date field in the table, I am unable to do it.
My requirement is how to convert the text field to date field and store in the table? I have searched in the forum, but I could not able to fine the solution.
Can anyone help me in achieving this?
Thanks,
Aravindh.
0
Comments
-
How's the date field value in text format?0
-
Hi Vijay,
02011062201400200000001 - are the data in text file.
Fieldwise
Field 1 - 0
Field 2 -20110622: This is the format of the date field in text format (yyyymmdd)
Field 3 - 01
Field 4 - 4002
Field 5 - 00000001
Thanks,
Aravindh.0 -
Use the COPYSTR function to parse the data into substrings and build your date using DMY2DATE. You'd have to import it into a temporary text variable instead of the actual date field.0
-
Hi,
Tried in different possibilities. Can you still more clear, how to approach?
Thanks,
Aravindh.0 -
Your Data::02011062201400200000001
Global Variables
ImportString->Text->250
isDay->Integer
isMonth->Integer
isYear->Integer
View->Dataport Fields->SourceExp-> (type in) ImportStringOnAfterImportRecord() EVALUATE(isYear, COPYSTR(ImportString,2,4)); EVALUATE(isMonth, COPYSTR(ImportString,6,2)); EVALUATE(isDay, COPYSTR(ImportString,8,2)); "YourTable".Field1 := COPYSTR(ImportString,1,1); "YourTable".Field2 := DMY2DATE(isDay, isMonth, isYear); "YourTable".Field3 := COPYSTR(ImportString,10,2); "YourTable".Field4 := COPYSTR(ImportString,12,4); "YourTable".Field5 := COPYSTR(ImportString,16,8);
If the key fields need validation it would be like:://ie.
VALIDATE("YourTable".Field1, COPYSTR(ImportString,1,1));
The 4 fields other than the date field are type TEXT.
If the field you are importing to are not type text //ie Integers or something use EVALUATE.
Save->Compile->Enjoy0 -
Thanks Savatage. It works perfect. How to handle the text file which contains characters around 2300?
Aravindh.0
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
- 322 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
