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)

convert utcdatetime control to date

(0) ShareShare
ReportReport
Posted on by 2,050

i know maybe my question so easy but i have utcdatetime control and i want use it to calculate and convert it to date type on my code 

control name is (EmpStartDate) from type utcdatetime

so i write this but still give me error how can i convert that control from utcdatetime to date and here's my code 

date startdate = EmpStartDate;

i did even this 

date startdate = DateTimeUtil::date(EmpStartDate);

but i got this error 

Argument 't' is incompatible with the required type.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: convert utcdatetime control to date

    DateTimeUtil::date([utcDateTime]) will work. But did you notice that you are actually trying to assign the EmpStartDate control (an object of type FormDateControl) to your startDate variable. You should take the value from that control using EmpStartDate.dateValue().

  • Suggested answer
    Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: convert utcdatetime control to date

    You need to understand  what type of parameter  values method accepts. EmpStartDate is your control not its value, so unless you pass value to date method you are not going to get results .

    Another thing you are assigning  control of datetime to date . Remove below line , its of no use

    date startdate = EmpStartDate;

  • Blue Wang Profile Picture
    on at
    RE: convert utcdatetime control to date

    Hi Mohammed,

    Please refer this code:

    utcdateTime  testDonedateTime1;
    utcdateTime  testDonedateTime;
    transdate    tmpDate ;
    timeofday    tmpTime;
    
    testDonedateTime1 = inventJournalTable.PostedDateTime;
    testDonedateTime  = DateTimeUtil::applyTimeZoneOffset(testDonedateTime1, DateTimeUtil::getUserPreferredTimeZone())
    tmpDate = DateTimeUtil::date(testDonedateTime);
    tmpTime = DateTimeUtil::time(testDonedateTime);  


    Important : utcDateTime control properties TimeZonePreference set No conversion
  • mohammed.mqi Profile Picture
    2,050 on at
    RE: convert utcdatetime control to date

    thanks all for replays and those info all was really useful

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans