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, ...
Unanswered

Select statement on valid time state tables

(0) ShareShare
ReportReport
Posted on by 636

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
    636 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,843 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 580

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 274 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans