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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Operator '!=' cannot be applied to operands of type 'utcdatetime' and 'date'.

(0) ShareShare
ReportReport
Posted on by 390

Hey Team,

I want to compare the dates in various tables like HCmPositionDetail an my custom table and if they are not same I want to update them in the respective table.

I wrote my code this way but I'm getting an error "Operator '!=' cannot be applied to operands of type 'utcdatetime' and 'date'.". How can resolve this issue. Please help me.

Hcmpositiondetail positionDetail;
 AssociateTable associate;
  if(positionDetail.ValidFrom != associate.StartDate)
        {
            positionDetail.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
            positionDetail.ValidFrom = associate.StartDate;
            positionDetail.update();
        }
        if(positionDetail.ValidTo != associate.EndDate)
        {
            positionDetail.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
            positionDetail.ValidTo = associate.EndDate;
            positionDetail.update();
        }

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    You want to compare two dates, but you are trying to compare a datetime with a date. So, you need to do conversion so that you can compare two variables of the same type.

    You can convert a utcDateTime variable to a date by using DateTimeUtil::date() function.

  • skd Profile Picture
    390 on at

    Hey Nikolaos Mäenpää,

    Thank you so much. It worked for me.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans