Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Business Central

(0) ShareShare
ReportReport
Posted on by 200

Hour-get.png

Hi,

As shown in the image i want the find count of sales order between ( from 7am to 7pm) and I want count for sales order between one hours like (7am-8am) how can be done

Please help in Al code if possible

 procedure hrorderpacked()

    var

        rec_SalesShipmentHeader: Record "Sales Shipment Header";

        rec_HourordersPackedByPacker: Record "Hour Order packed";

        rec_User: Record User;

        curr_Time1: DateTime;

        curr_Time2: DateTime;

        Diff_Duration: Duration;

    begin

        if rec_User.FindSet()

        then

            repeat

                rec_SalesShipmentHeader.SetCurrentKey(SystemCreatedAt);

                rec_SalesShipmentHeader.SetAscending(SystemCreatedAt, true);

                //rec_SalesShipmentHeader.SetRange("Posting Date", Today - 31, Today);

                rec_SalesShipmentHeader.SetRange("User ID", rec_User."User Name");

                if rec_SalesShipmentHeader.FindSet()

                then

                    repeat

                        rec_HourordersPackedByPacker.SetRange(Username, rec_User."User Name");

                        if rec_HourordersPackedByPacker.findSet() then begin

                            case (rec_SalesShipmentHeader.SystemCreatedAt) of

                                CurrentDateTime - 3600000 / 7:

                                    rec_HourordersPackedByPacker.Before7AM := rec_HourordersPackedByPacker.Before7AM + 1;

                            end;

end;

This code is what I tried, please help in this one.

Thankyou.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    Not getting the expected result is there any more suggestions in Al code where I can get the last hour post sales shipment count?

    2) how can get total count? For last hours 

    Please help in this as also?.

    As I am beginner in business Central.

    Thankyou.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    Ok, Thankyou, and also can check last hour with current time? Right?

  • Verified answer
    Raviraj2277 Profile Picture
    Raviraj2277 185 on at
    RE: Business Central

    You can use above procedure CountBetween7to8()  by changing DT and DT2 variable value to last hour start and end time.    example if your last hour is 7pm to 8 pm then add it to DT and DT2.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    last-hour.png

    Here I want to only show count of sales order for last hour only now show how to check that ? 

    Thankyou 

  • Raviraj2277 Profile Picture
    Raviraj2277 185 on at
    RE: Business Central

    You can make this process dynamic by increasing Date time by one hour.  Or simple you can create separate procedure for each hour.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    6366.Hour-get.png

    Hi, this example is ok but as shown in image I want to find hour break down, that is one hour break down from 7AM to 7PM how that can be done but? 

    For each hour difference how can be done ? Can you give some example for that.

    Thankyou.

  • Raviraj2277 Profile Picture
    Raviraj2277 185 on at
    RE: Business Central

    This is simple example  to calculate count between 7 am to 8 am

    local procedure CountBetween7to8()

       var

           Rec_SalesHeader: Record "Sales Header";

           DT: DateTime;

           DT2: DateTime;

           CountBetwee7to8: Integer;

       begin

           DT := CreateDateTime(Today, 070000T);

           DT2 := CreateDateTime(Today, 080000T);

           Rec_SalesHeader.SetRange(SystemCreatedAt, DT, DT2);

           CountBetwee7to8 := Rec_SalesHeader.Count;

       end;

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: Business Central

    But,This is to summarise only  count, but I want to display count between hours i e (7am-8am) ,between this i want to count so how can we do that.

    Thankyou 

  • YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    RE: Business Central

    Hi, It looks like you want to summarize the data on one line, hope the following information can give you some hints.

    https://yzhums.com/28900/

    Thanks.

    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans