Format problem: MySQL datetime -> Navision datetime
Andre1977
Member Posts: 5
Hello,
I am quite new in programming C/Side Navision. Currently I use Navision Attain 3.70 and I have the following problem:
I have a variable "value" containing a MySQL datetime (Format: YYYY-MM-DD hh:mm:ss) and I want to store this in a Navision datetime (let´s call this field "datetime") field.
I know that I can store the date (without time) using the "Evaluate" function, but this does not seem to work with datetime:
This does not work:
datetime := EVALUATE(datetime,COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4)+COPYSTR(Value,12,2)+COPYSTR(Value,15,2)+COPYSTR(Value,18,2))
This does work:
datetime := EVALUATE(datetime,COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4))
How can I store the complete datetime including the hours,minutes and seconds?
I think this is no problem for experienced Navision programmers, but as I said before this is quite new to me.
Maybe someone could give me a hint how to solve this problem?
Kind regards
I am quite new in programming C/Side Navision. Currently I use Navision Attain 3.70 and I have the following problem:
I have a variable "value" containing a MySQL datetime (Format: YYYY-MM-DD hh:mm:ss) and I want to store this in a Navision datetime (let´s call this field "datetime") field.
I know that I can store the date (without time) using the "Evaluate" function, but this does not seem to work with datetime:
This does not work:
datetime := EVALUATE(datetime,COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4)+COPYSTR(Value,12,2)+COPYSTR(Value,15,2)+COPYSTR(Value,18,2))
This does work:
datetime := EVALUATE(datetime,COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4))
How can I store the complete datetime including the hours,minutes and seconds?
I think this is no problem for experienced Navision programmers, but as I said before this is quite new to me.
Maybe someone could give me a hint how to solve this problem?
Kind regards
0
Answers
-
How do you get the MySQL DateTime Value? Do you use ADO do connect to a MySQL DB :?:Do you make it right, it works too!0
-
An external developer built an interface to exchange data between Navision and MySQL.
This allows me to fill Navision fields from MySQL using specific functions.
Unfortunately the Navision "datetime" has not the same format as MySQL "datetime" so I have to format it somehow.
In Navision I have this "variable" including the datetime in the MySQL Formate (yyyy-mm-dd hh:mm:ss) which needs to be formatted in order to be stored correctly in a Navistion datetime field.0 -
how do you get the MySQL DateTime Value?
Is it in NAV "on the fly" if you enter it in the MYSQL DB or did you import a file or is in NAV a button that you press and this connect to the MySQL DB and get from there your data?
Runs your Navisiondatabse under native or sql?
EDIT: If it is for example, a textfile that you import, check the CREATEDATETIME (Date,time) function that Luc posted ...Do you make it right, it works too!0 -
Have a look at the online-help for the CREATEDATETIME function:CREATEDATETIME (Datetime)
Use this function to create a datetime from a date and a time.
DateTime := CREATEDATETIME(Date, Time)
DateTime
Data type: datetime
The concatenated datetime
Date
Data type: date
The date that you want to use to create a datetime.
You cannot use an undefined date to create a datetime.
Time
Data type: time
The time that you want to use to create a datetime.
You cannot use an undefined time to create a datetime.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Maybe my questions are too stupid or I have a problem explaining the problem correctly.
In Navision I have a string variable (name = "value") which is "2009-07-10 12:18:23" for example.
I want to store this in a navision database field (native db) which has datetime as datatype.
How can I format this string in order to make this work.
I just tested the following ways, but both did not work:
datetime := CREATEDATETIME(COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4),COPYSTR(Value,12,2)+COPYSTR(Value,15,2)+COPYSTR(Value,18,2))
datetime := CREATEDATETIME(EVALUATE(COPYSTR(Value,9,2)+COPYSTR(Value,6,2)+COPYSTR(Value,1,4)),COPYSTR(Value,12,2)+COPYSTR(Value,15,2)+COPYSTR(Value,18,2))
As I said I have poor skills in c/side programming and the online-help is not very helpful for me in this place.0 -
Try this:
Value := '2009-07-10 12:18:23'; EVALUATE(intDay,COPYSTR(Value,9,2)); EVALUATE(intMonth,COPYSTR(Value,6,2)); EVALUATE(intYear,COPYSTR(Value,1,4)); ValueDate := DMY2DATE(intDay,intMonth,intYear); EVALUATE(ValueTime,COPYSTR(Value,12,8)); datetime := CREATEDATETIME(ValueDate,ValueTime);
Variables used:Value Text 30 intDay Integer intMonth Integer intYear Integer ValueDate Date ValueTime Time
The function CREATEDATETIME requires parameters of type Date & Time, not strings containing a date & time.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
That´s it :-)
Thank you very much, Luc.
This time it worked, problem is solved.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 329 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
