Posts

Showing posts from June, 2011

Working with dates in x++

These are some good methods for working with the dates. today(); //Returns the current date date2Str(currentDate, 321, // sequence of date parts 3=year 2=month 1=day DateDay::Digits2, DateSeparator::Hyphen, // separator1 DateMonth::Digits2, DateSeparator::Hyphen, // separator2 DateYear::Digits4 ); str2Date("2011-06-30",321) // turns the string into a date mthofyr(today()) //returns the current month as a integer. year(today()) //returns the current year as a integer. dayofmth(today()) //returns the dat as a integer. If you are working UTCDates that was introduces in AX 2009 there is a class called DateTimeUtil that contains all the functions that is needed. For utcdates use datetimeutil::utcNow() instead of today() Records that are displayed in ax without a date are stored in the database as 1900-01-01.