Convert Date to Text

attardcattardc Member Posts: 97
Now I have a Date field which I'd like to convert it or copy it into another variable of the type Text. !!

I'm using MS Dynamics NAV 5.

Any help appreciated!

Comments

  • maheshmahesh Member Posts: 115
    Date : Dt
    Text : Txt

    Txt := Format(Dt); -- this code will convert Date field to Text.
    Best Regards,
    Mahesh Jain
    mahesh@reliconservices.com
  • BeliasBelias Member Posts: 2,998
    Precistion: "format" convert each data type to text.
    mahesh instruction fits with each datatype

    O.T.: :mrgreen: This christmas smile is AMAZING!!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • WaldoWaldo Member Posts: 3,412
    There is quite much possible with the FORMAT-statement. Just look for the format statement and property in the help.
    Here are some examples of how to use the Format property:

    Choosing a standard format:

    Use the Standard Format attribute to select one of the standard formats (these are listed at the end of this Help topic).

    For example, <Standard Format,5> will select Standard Format 5.

    Using a standard format with an attribute:

    <Precision,2:3><Standard Format,0> will use Standard Format 0 and will format the data with a minimum of 2 and a maximum of 3 decimal places. See also the DecimalPlaces property. If you do not specify any precision the form will use the precision specified in the Decimal Places property of the corresponding field in the table.

    Building a Format

    You can create your own formats by using Chars (which will be displayed literally), Fields (to choose specific components of a value, for example the year-part of a date) and Attributes (for example to select which character to use as a filler).

    For example, a text box based on a source expression of the Date data type, that uses the following format string:

    <Weekday Text>, <Month Text> <Day>

    will display the date as: Monday, April 15

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • cunnycunny Member Posts: 129
    Hey guys,

    DO NOT forget standard codeunit 6201 Conventions, You will get a shock :lol:
    cunny Lee
    MCP - MBS Navision
    jle@naviworld.com
  • WaldoWaldo Member Posts: 3,412
    :|
    And what do you mean?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • EugeneEugene Member Posts: 309
    DateToText(VarDate : Date) : Text[8]
    IF VarDate = 0D THEN
      VarText := '17530101'
    ELSE
      VarText := FORMAT(VarDate,0,'<Year4><Month,2><Day,2>');
    EXIT(VarText);
    

    wth, could not they at least check for MS SQL option with RECORDLEVELLOCKING function before setting 1753.01.01 ?
  • cunnycunny Member Posts: 129
    Instead of spending lots of time to figure out how to write some critical basic functions I would prefer to figurre out how Navision handle them now. As much as I can. Until today, there are many many useful functions which are integrated into standard codeunits, we can use them as much as we can and spend time on business logic coding. Actually, "reading codeunits" is very helpful for me, I found lots of useful staff within Navision.

    Good Luck,
    cunny Lee
    MCP - MBS Navision
    jle@naviworld.com
  • WaldoWaldo Member Posts: 3,412
    in fact, the book of David Studebaker "Programming MS Dynamics NAV" handles some useful codeunits:
    http://www.packtpub.com/Microsoft-.NET- ... ision/book

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.