String to Date Conversion

roshanthaparoshanthapa Member Posts: 90
I have developed a program to convert gregorian date to islamic and vice-versa. I had to make certain calculations on the day, month and year.....

Now I have the date in three variables say, day, month and year. And I have to concatenate this and convert to date type...... This is where the problem is. How should I concatenate the day, month and time so that it's in the correct format as the system can accept.


Supporting example:
If I concatenate them as dd/mm/yy then and the systems date format is mm/dd/yy, the system will generate error for dd=20 (date), because when I concatenated, it went to the place where month should be..... so it has to be dynamic as according to the date format of the system. Is there any method to get the date format of the system???

Comments

  • BeliasBelias Member Posts: 2,998
    at the beginnig of your process, You can read the virtual table "date" line by line until you find a date with month > 12. If you find one, exit the loop and valorize a boolean (in this case the format is mmddyy) otherwise don't valorize the boolean (because the format is ddmmyy).

    then when you have to valorize the date you can refer to the value of the boolean and select the correct format.
    this method function only with non-empty DB.
    It's a nice workaround as I don't know how to get the regional settings of windows... :mrgreen: :oops:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • roshanthaparoshanthapa Member Posts: 90
    Now, I have developed another algorithm to tackle this problem and its fast too... Now I don't need the regional settings too.

    I soved it!!!
  • kinekine Member Posts: 12,562
    And do not forget that you have DMY2DATE function to create date from Day, Month and Year values... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • roshanthaparoshanthapa Member Posts: 90
    Thanks Kine, thanx for reminding me about this function..... This saved my time. I didn't know this function, Now I'll check the whole help file for these kinda functions....


    Thanks again....
Sign In or Register to comment.