web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

how to get the Date instead of Datetime in Ax 2012 r3

(0) ShareShare
ReportReport
Posted on by 1,737

I am writing the code to get the data from ax in to excel, but date field is coming is like as 01-05-2016 10:23:34

i want only date..

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,859 Most Valuable Professional on at
    RE: how to get the Date instead of Datetime in Ax 2012 r3

    You can easily convert datetime to date, but I can't comment on your code, because you didn't tell us anything about it. Also you can change the format in Excel.

  • Mea_ Profile Picture
    60,284 on at
    RE: how to get the Date instead of Datetime in Ax 2012 r3

    Hi srinivas pamidi,

    You can use DateTimeUtil::date() to convert date time to date in x++ code.

  • srinivas pamidi Profile Picture
    1,737 on at
    RE: how to get the Date instead of Datetime in Ax 2012 r3

    Hi ievgen Miroshnikov,

    In Debugger it is showing Date in excel sheet it is showing as Date time.

    I am already Try this But it is Showing Error.

    Argument 't' is incompatable with the required type.

    xlsWorkSheet.cells().item(row,2).value(DateTimeUtil::date(budgetTmpBalanceLocal.Period));

  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    RE: how to get the Date instead of Datetime in Ax 2012 r3

    budgetTmpBalanceLocal.Period is already a date so you cannot convert date to date.

    Could you please try to use xlsWorkSheet.cells().item(row,2).value(strfmt('%1', budgetTmpBalanceLocal.Period));

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: how to get the Date instead of Datetime in Ax 2012 r3

    This will work :)

    xlsWorkSheet.cells().item(row,2).value(date2Str(budgetTmpBalanceLocal.Period, 123, 2, DateSeparator::Hyphen, 2, DateSeparator::Hyphen, 2,true));

    Output:

    01-05-2016

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans