Friday, April 24, 2015

Date functions in ax 2012

Date Functions in ax 2012


1.dayName Function:
Retrieves the name of the day of the week specified by a number.
Syntax:
str dayName(int number)

Example:
Note:
The valid values for the number parameter are 1 through 7. Monday is represented by 1, Tuesday by 2, and Sunday by 7.
    str s;
    s= dayName(4);
    info(strFmt("fourth day of a week is %1",s));

Op: fourth day of a week is Thursday

2.dayOfMth Function:

Calculates the number of the day in the month for the specified date.

Syntax:

int dayOfMth(date date)
 
Example:
Note:
An integer between 1 and 31 that indicates the day of the month for the specified date.
Date format:
 
    int i;
    ;
    i = dayOfMth(11\6\2014);  
    info(strFmt("today's day of the month is %1",i));
Op: today's day of the month is 11

or

    info("today's day of the month is");
    info(int2str(i));
Op: today's day of the month is
     11


or
    int i;
    ;
    i=dayOfMth(today());
    print "today’s day of month is "+int2str(i);
    pause;
op: returns today’s day of month is 24


3.dayOfWk Function:

Calculates the number of day in the week for the specified date.

Syntax: int dayOfWk(date date)
 

Example:

    int i;
    ;
    i=dayofwk(today());
    print "todays day of Week is "+int2str(i);
    pause;
op: todays day of Week is 5


4.dayOfyr Function:
Calculates the number of days between January 1 and the specified date.
Syntax: int dayOfYr(date _date)

Example:

int i;
    ;
    i=dayofyr(today());
    print "todays day of year is "+int2str(i);
    pause;

op: todays day of year is 114.

5.mthOfYr Function:

Retrieves the number of the month in the year for the specified date

Syntax:

int mthOfYr(date date)

 

Example:

    int i;
    ;
    i=mthofyr(today());
    print "Current month of year is "+int2str(i);
    pause;

op: Current month of year is 4.

 

6.wkOfYr Function:

Calculates the week of the year in which a date falls, according to the ISO 8601 specification.

Syntax : int wkOfYr(date _date)

 

Example:

    int i;
    ;
    i= wkOfYr(today());
    print "Current week of year is "+int2str(i);
    pause;

op: Current week of year is 17.

7.year Function:

Retrieves the year from a date value.

Syntax: int year(date _date)

 

Example:

    int i;
    ;
    i= year(today());
    print "Current year is "+int2str(i);
    pause;

 

op: Current year is 2015

8.endmth Function:

retrieves last date of month of the specified date;

Syntax: date endMth(date date)

Example:

   int i;
   ;   
   print endmth(today());
   pause;

 op:30/04/2015

9. maxDate Function:

Retrieves the maximum value allowed for a variable of type date.

Syntax:date maxDate()

Example:

    date maximumdate;
    ;
    maximumdate=maxDate();
    print maximumdate;
    pause;
   

       op:12/31/2154

 

10.mkDate Function:

Creates a date based on three integers, which indicate the day, month, and year, respectively.

Syntax:

date mkDate(int day, int month, int year)

 Example:

Date _CustomDate;
Date _LastDateOfMonth;
Int month_number;
Int years_numbers;
Int day_number;
;
Day_number=1;
Month_number=4 ; // say April
years_numbers=2014;
_CustomDate =mkdate(Day_number, Month_number, years_numbers);

info(strFmt("%1",_CustomDate));
op:
4/1/2014

                        Or
    date d;
      ;

    // Returns the date 01\01\2005.
    d = mkDate(04, 1, 2015); 
    print d;
    pause;
    op:4/1/2015;

11.mthName Function:

Retrieves the name of the specified month

Syntax: str monthName(int number)
 
Example:
     str s;
    s = mthname(12);
    info(strFmt("%1",s));
    Op:December
 

12.nextMth Function:

Retrieves the date in the following month that corresponds most closely to the specified date.

Syntax:

date nextMth(date date)

Example:

 date s;
      s = nextMth(5\6\2014); or s= nextMth(today());
      info(strFmt("%1",s));

 op: 7/5/2014

13.nextQtr Function:

Retrieves the date in the following quarter that corresponds most closely to the specified date.

Syntax: date nextQtr(date date)

Example:

    date d;
    ;
    d = nextQtr(today()); or  d= nextQtr(5\6\2014);
    info(strFmt("%1",d));//op: 9/5/2014

 

14.nextYr Function:

Retrieves the date in the following year that corresponds most closely to the specified date.

Syntax:

date nextYr(date date)

date d;
    ;
    d = nextYr(today());
    info(strFmt("%1",d));

or

date d;
    ;
     d= nextYr(5\6\2014);
    info(strFmt("%1",d));//op: 6/5/2015

 

15.prevMth Function:

Retrieves the date in the previous month that corresponds most closely to the specified date.

Syntax:

date prevMth(date date)
 
Example:
date d;
    ;
    d = prevMth(5\6\2014);
    info(strFmt("%1",d));
op:5/5/2014
   
 

16.prevYr Function:

Retrieves the date in the previous year that corresponds most closely to the specified date.

Syntax:

date prevYr(date date)

 

Example:

date d;
    ;
    d = prevyr(5\6\2014);
    info(strFmt("%1",d));
op: 6/5/2013

17.prevQtr Function :

Retrieves the date in the previous quarter that corresponds most closely to the specified date.

Syntax:

date prevQtr(date date)

 

Example:

date d;
    ;
    d = prevqtr(5\6\2014);
    info(strFmt("%1",d));

op: 3/5/2014;

18.timeNow Function:

Retrieves the current system time.

Syntax: int timeNow()
Note: The number of seconds that have elapsed since midnight.
 

Example:

    int d;
    ;
    d = timeNow();
    info(strFmt("%1",d));// op: 61781

19.today Function:
Retrieves the current date on the system.
 
Syntax: date today()
 

Example:

    date d;
    ;
    d = today();
    info(strFmt("%1",d));

Op: 4/24/2015



<<=Keep Daxing !!!=>>

<<=HaPpYyY  Daxing :)=>>


 

 



 

 





4 comments:

  1. Hi! How can I add days? Any method like prevDay or nextDay?
    Thanks!

    ReplyDelete
  2. How can I get the week of a month?

    ReplyDelete
  3. Hi Jeffrey,

    to get Previous day you have use "today()-1";
    to get Next day you have to use "today()+1";

    ReplyDelete
  4. Microsoft Helpline Number is totally free for customers +1-844-728-4045 who are having problem with their Microsoft Office, Outlook, Windows or any other kinds of software’s

    Toll-free:- +1-844-728-4045
    Email – support@wconferenceweb.com
    Website: - https://microsoft.wconferenceweb.com

    ReplyDelete

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...