Format date

The following line “FORMAT(“Sales Invoice Header”.“Document Date”,0,4)” gives me the date on this format: “7. desember 2010”.

How do I get “7.12.2010” ?

hi Andreas,

use this method to convert your date to string,

static void date2StrExample(Args _arg)
{
date d = today();
str s;
;
s = date2Str(d, 123, 2, -1, 2, -1, 4);
print "Today’s date is " + s;
pause;
}
this will return 08/12/2010.

Regards,

Mehul Thacker

Hi Mehul and thank you for your reply!

This looks like a complicated solution, since the field “Document Date” allready is on the format 07.12.2010…

Can I just show it like it is?

Mehul,

question is for NAV and not Ax.

I believe you are using Europian Date format and I think none of the format gives you exactly what you are looking for. You might want to try:

“FORMAT(“Sales Invoice Header”.“Document Date”,0,1)”

Following is what on-line help says about various date format:

For Dates, the Regional and Language Options in Windows is used to select the actual format that is used. The table below shows the Fields that will be used to build the various formats. This table, incidentally, corresponds to the Regional setting for a European country/region.

Date

Format

Example

<Day,2>-<Month,2>-

0

05-04-03

<Day,2>-<Month,2>-

1

05-04-03

<Day,2><Month,2>D

2

050403D

-<Month,2>-<Day,2>

3

03-04-05

.

4

  1. April 2003

<Day,2><Month,2>

5

050403

<Month,2><Day,2>

6

030405

<Day,2><Filler Character, >. <Month Text,3>

7

  1. Apr 2003

XML format

9

2003-04-05

The following table shows how these formats will change if the Regional and Language Options is set to “United States.”

US Date

Format

Example

<Month,2>/<Day,2>/

0

04/05/03

<Month,2>/<Day,2>/

1

04/05/03

<Month,2><Day,2>D

2

040503D

/<Month,2>/<Day,2>

3

03/04/05

,

4

April 5, 2003

<Month,2><Day,2>

5

040503

<Month,2><Day,2>

6

030405

<Day,2><Filler Character, >. <Month Text,3>

7

  1. Apr 2003

Hi Dhan!

This is close enough!

Thanks!