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

Announcements

Community site session details

Community site session details

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

Range value on Datetime fields

(1) ShareShare
ReportReport
Posted on by 439
Hello 
I have a view with a utcdatetime field  "PO created date time" and trying to filter data on it. Using the view on form as datasource
 
I have added 2 fields on the form for from date and to date to filter the data. 
 
I am trying to filter the data using below code in Execute query method and doesn't work
fDateTime = ctrlFromDate.dateTimeValue();
tDateTime = ctrlToDate.dateTimeValue();

startDate   = DateTimeUtil::date(fDateTime);
endDate     = DateTimeUtil::date(tDateTime);

startTime   = str2time("08:30:00 am");     
endTime     = str2time("09:00:00 am");

rangeStart = DateTimeUtil::newDateTime(startDate,startTime);
rangeEnd   = DateTimeUtil::newDateTime(endDate,endTime);

this.query().dataSourceTable(tableNum(ReceiptLinesView)).clearRange(fieldNum(ReceiptLinesView, POCreatedDateTime));

this.query().dataSourceTable(tableNum(ReceiptLinesView)).addRange(fieldNum(ReceiptLinesView, POCreatedDateTime)).value(queryRange(rangeStart, rangeEnd));
I tried to hard code like this below with almost same code and it works, but I want to dynamically filter using form controls by above method. 
 
startDate   = 01\09\2025;       // day\month\year
            endDate     = 24\09\2025;     // day\month\year

            startTime   = str2time("08:30:00 am");     //GMT, NOT user time zone - this is how stored in the table
            endTime     = str2time("09:00:00 am");
                        
            rangeStart = DateTimeUtil::newDateTime(startDate,startTime);
            rangeEnd   = DateTimeUtil::newDateTime(endDate,endTime);

            this.query().dataSourceTable(tableNum(ReceiptLinesView)).clearRange(fieldNum(ReceiptLinesView, POCreatedDateTime));

            this.query().dataSourceTable(tableNum(ReceiptLinesView)).addRange(fieldNum(ReceiptLinesView, POCreatedDateTime)).value(queryRange(rangeStart, rangeEnd));
I am clueless on what is going on
 
I have the same question (0)

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
André Arnaud de Calavon Profile Picture

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

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 280 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 213 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans