DAXSPOT

Sunday, December 4, 2022

X++ function date2Str()

 Hi,

This post is about the X++ function date2Str(). This Function Converts the specified date to a string.

http://msdn.microsoft.com/en-us/library/aa857241.aspx


str date2Str(

    date date,

    int sequence,

    int day,

    int separator1,

    int month,

    int separator2,

    int year

    [, int flags = DateFlags::None])

Parameters

Parameter

Description

date

The date to convert.

sequence

A three digit number that indicates the sequence for the components of the date, 1 for day, 2 for month, and 3 for year.

day

A DateDay enumeration value that indicates the format for the day component of the date.

separator1

A DateSeparator enumeration value that indicates the separator to use between the first two components of the date.

month

A DateMonth enumeration value that indicates the format for the month component of the date.

separator2

A DateSeparator enumeration value that indicates the separator to use between the last two components of the date.

year

A DateYear enumeration value that indicates the format for the year component of the date.

flags

A DateFlags enumeration value that indicates whether the language settings on the local computer should be used to calculate the proper left-to-right or right-to-left sequence in the returned string.


Return Value

A string that represents the specified date.


X++ Example:

static void Job2(Args _args)

{

    date currentDate = today();

    str s;

    int iEnum;

    ;

    s = date2Str

        (currentDate,

        321,

        DateDay::Digits2,


        DateSeparator::Hyphen, // separator1

        DateMonth::Digits2,

        DateSeparator::Hyphen, // separator2


        DateYear::Digits4

        );

    info("Today is:  " + s);

}

/** Example Infolog output

Message (12:36:21 pm)

Today is:  2009-01-13

**/

Thank you,

Thursday, December 1, 2022

Calculate Days and Month of Date - X++

Hi,

In this post we will be related to days and month of Date.

In below sample of code you to get example for following point:

    1. Start date of the month.

    2. End date of the month.

    3. Total number of days in the month.

    4. Remaining number of days in the month.


static void days_Example(Args    _args)

{

    int FromDays, ToDays;


    info(strFmt("Today date is %1", today()));    

    

    // Displays start date of the month for the given date.

    info(strFmt("Start date is %1 for the month of %2", date2str(DateStartMth(Today()),213,2,4,2,4,4), mthName(mthOfYr(today()))));


    // Displays end date of the month for the given date.

    info(strFmt("End date is %1 for the month of %2", date2str(endmth(Today()),213,2,4,2,4,4), mthName(mthOfYr(today()))));


    // Displays total number of days in the month for the given date

    FromDays = date2num(DateStartMth(today()));

    todays = date2num(endmth(today()));

    info(strFmt("There are total %1 days in month %2", (ToDays+1) - FromDays, mthName(mthOfYr(today()))));


    // Displays remaining number of days in the month for the given date

    FromDays = date2num(DateStartMth(today()));

    todays = date2num(today());

    info(strFmt("%1 days are remaining in the month of %2", (ToDays+1) - FromDays, mthName(mthOfYr(today()))));

}


Thank you,

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...