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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

How to get the current employment start date of employee from employment history

(1) ShareShare
ReportReport
Posted on by 3,045

Hello Everyone,

I am creating RunBase class and exporting employee data in excel format. Requirement is at runtime we will provide 2 dates which is compared with Employment StartDate in Employment history form (HCMEmployment.ValidFrom). Employement Start date is the ValidTimeState field in the HCMEmployment table. 

Based on Users time zone the employment StartDate field value is changed but in DB it will store same value which we have entered.

e.g: if I am in India time zone and enter the value 31/12/2021 12:00:00 AM. When we change the user time zone to US or pacific zone it is changed to 01/01/2022 06:30:00 PM. In table field store the value " 31/12/2021 12:00:00 AM" this doesn't change.  

So, whenever we run the report in US time zone and select the date 01/01/2022 it is generating blank report because table store 31/12/2021. 

How can I handle this problem? 

Thanks.

I have the same question (0)
  • Verified answer
    Parag Chapre Profile Picture
    12,254 Most Valuable Professional on at

    Hi Pooja,

    You need to write below code in your class.

    HcmEmployment hcmEmployment;
    ValidFromDateTime dateFrom = DateTimeUtil::minValue();
    ValidToDateTime dateTo = DateTimeUtil::maxValue();
    Timezone usertimezone = DateTimeUtil::getUserPreferredTimeZone();
    utcdatetime utcFieldTimeBeginOfDay = DateTimeUtil::newDateTime(DateTimeUtil::date(datetoValidate), 0, usertimezone);
    utcdatetime utcFieldTimeEndOfDay = DateTimeUtil::newDateTime(DateTimeUtil::date(dateToValidate), #secondsPerDay - 1, usertimezone); // 23:59:59 of the day

    In above case, you can use utcFieldTimeEndOfDay to get the value save in 23:59:59 format.

    Please try above code and get back to me.

  • Suggested answer
    Pooja Karki Profile Picture
    3,045 on at

    thanks for answer it works.

  • Suggested answer
    Parag Chapre Profile Picture
    12,254 Most Valuable Professional on at

    Hi Pooja, Can you please mark the answer as verified so that it can help others.

  • Pooja Karki Profile Picture
    3,045 on at

    Sure, will do that.

    I just wanted to know if I want to print the changed date in report how I can do that?

    If I changed time zone and whatever value is coming in Form same needs to print in report.

  • Parag Chapre Profile Picture
    12,254 Most Valuable Professional on at

    Hi Pooja,

    Is value in the form based on usertimezone or companytimezone?

  • Pooja Karki Profile Picture
    3,045 on at

    It is in Usertimezone.

  • Pooja Karki Profile Picture
    3,045 on at

    It is done thanks.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 258 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans