Of course the format must be same as set in regional settings else the application do not know what is year, month and day... you must convert the string before converting into date... (switch to format ddmmyyyy for example)
Yeah, we can write our own function for that, just like what you suggest.
I thought it is a very common task in programming, and I thought it should be something build-In function for that, like str2Date(Format).... but there is no such build-In function. Seem like Navision is very lacking of build in function for development.
It is nothing about lacking functionality, it is about date format, that is controlled through system settings, and if you need another format, you must change it... :-) it is simple task and do not need special function for that... keep C/AL functions simple... you have simple tools for complex things...
Seem like Navision is very lacking of build in function for development.
Sorry, but I had to laugh about that. Please imagine you have to write every database request by yourself (as: "SELECT * FROM table WHERE id=10000 ORDER BY sort") instead of creating a record var and using SETRANGE. I think there are many build in functions for development.
<snip>
....I thought it should be something build-In function for that, like str2Date(Format).... but there is no such build-In function.
.... </snip>
DMY2DATE is one of those functions. Open the object browser (hit F5), scroll down to where it says SYSTEM, and click on 'Date' in the middle pane. You will find all sorts of built in date functions.
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Evaluate give me error.
Date: MyDate
Evaluate(myDate, '20050401');
This gives me a run time error. Seem like evaluate only work when the date format is the same as the window regional setting.
Any idea?
Ken
This code convert yyyymmdd to ddmmyyyy for example...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Yeah, we can write our own function for that, just like what you suggest.
I thought it is a very common task in programming, and I thought it should be something build-In function for that, like str2Date(Format).... but there is no such build-In function. Seem like Navision is very lacking of build in function for development.
Anyway, thanks for all of you.
Ken
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
RIS Plus, LLC