Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

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

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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 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));

  • srinivas pamidi Profile Picture
    srinivas pamidi 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));

  • Mea_ Profile Picture
    Mea_ 60,278 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.

  • Martin Dráb Profile Picture
    Martin Dráb 230,030 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,188 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans