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 :
Small and medium business | Business Central, N...
Answered

Compare Time Values in Formulas

(0) ShareShare
ReportReport
Posted on by

I have Table A with Date and Time as separate columns. The time value is entered as 1800 for each record - which translates to 6:00pm. 

I have Table B with a transaction that has a transaction time. Depending on that time - I need to retrieve a value from Table A. If the time entered in Table B is equal to or after 6:00pm I get the record with today's date. If the time entered in Table B is before 6:00pm I get the record with the previous day's date.

Table A

Date               Time               Value

10/12/21         1800               1.01

1013/21          1800               1.30

10/14/21         1800               1.10

Table B

Date             Time             Value Expected

10/13/21       1909             1.30

10/13/21       1230             1.01

I can't seem to do a < comparison with my Time field to the constant of 1800. I tried to format the time field to be able to compare it to '06:00:00 PM' since that is the text value of 1800 but the result is True no matter what the Time value is.

Any help would be greatly appreciated. Thank you.

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,718 Super User 2025 Season 2 on at

    Hi, have you tried to compare them after changing them to the same Type value?

    EVALUATE Function:

    https://docs.microsoft.com/en-us/dynamics-nav/evaluate-function

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-evaluate-method

    Hope this will help.

    Thanks.

    ZHU

  • MHalton Profile Picture
    on at

    Thank you for the response ZHU.

    It evaluates to 7:09:00 PM if I were to enter 1909 in my page. When I run

    If format(recDetail."Time") < ('6:00:00 PM') then ...

    It processes the If statement as True even though it is not in this example.

    If someone could even help me to determine the hh (hours) portion of the time value as held in the tables, then I could just compare the integers but I can't find anything to break out that portion of the field either.

    Thank you for your help.

  • Verified answer
    MHalton Profile Picture
    on at

    Found the solution.

    I converted my transaction Date and  Time fields into a single DateTime field. I compared this to a calculated date field of Date entered + 1 and 00000T to equate to midnight of the next day.

    Using this post (https://yzhums.com/9273/)- I then calculated the duration of entered time versus check date. If the duration is more than 21,600,000 ms (6 hours to match up to the hours between 6pm & midnight) then I was able to check my data correctly in my if...then block.

    Thank you.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans