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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Select statement on valid time state tables

(0) ShareShare
ReportReport
Posted on by 634

Hi Experts,

Below is a sample table where the valid time state field type is selected as Date in the table properties. I need to select the first record in my code (the first record created as per the Rec id in the table), the record with salary 1000 in the below case but the select statement brings the current record only which is the last one since the table is date effective. what should be the statement to get the first record ? Thanks in advance. 

Employee  Valid From Valid To Salary
123 01/01/2020 31/12/2020 1000
123 01/01/2021 31/12/2021 2000
123 01/01/2022 31/12/2022 3000
I have the same question (0)
  • Jeson Profile Picture
    120 on at

    Try this code: 

    Select firstonly table order by RecId asc;

  • D365  beginner Profile Picture
    634 on at

    Thanks Jeson for your reply. I had tried the same already but it doesn’t work. I need to know that if the table is date effective, the normal select statement would  work or not.

  • Jeson Profile Picture
    120 on at

    pastedimage1662431842973v1.pngpastedimage1662432082484v2.pnghonestly for now i don't really know whats the mystery behind that but i found solution. You just create view for that particular table and set the order by to ascending order and use the this code to get the first RecID  ( select firstOnly view order by RecId asc). 

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    For this scenario you need to mention the from and to date using validtimestate.

    Validfrom fromDate = 01\01\2020;
    ValidTo toDate = 12\31\2020;
    
    Select validtimestate(fromDate,toDate) * from table;

    Thanks,

    Girish S.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans