Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Determine last Sunday in March and October

    Posted 05-02-2025 11:31

    We want to enable the callback features between specific hours of the day, I found however that during summer time the current schedule is an hour off due to the time shift and therefore had to manually update all the corresponding times. I would like to be able in architect flows to automate this so we don't have to change every time the tables that hold the times. We know the BST kicks in on the last Sunday of March and ends the last Sunday of October. What is the best way to identify these days within a flow?


    #Architect

    ------------------------------
    Ruud Reinold
    BNP Paribas Personal Finance UK
    ------------------------------


  • 2.  RE: Determine last Sunday in March and October

    Posted 05-07-2025 18:45

    This works for us to do time checks. Should ne enough info for you to figure out your requirements

    I think you are looking at the GetDayOfWeekOccurence() function

    To determine whether to add Daylight Savings or Non-Daylight Savings time to the current UTC time, we need to understand if the current Date and Time is before or after when Daylight Savings starts or ends (please see Time zones and daylight saving | australia.gov.au for official reference).  Once that is determined, you can then add the appropriate hours or minutes to the UTC time to get the current time in that Timezone.

    Using AddHours

    Example is for Melbourne/Sydney. +10 Hours (Non-Daylight Savings)/+11 Hours (Daylight Savings)
    AddHours(GetCurrentDateTimeUtc(),If(AddHours(GetCurrentDateTimeUtc(),10) < GetDayOfWeekOccurrence(1,1,Year(AddHours(GetCurrentDateTimeUtc(),10)),4,2,0,0),11,If(AddHours(GetCurrentDateTimeUtc(),10) > GetDayOfWeekOccurrence(1,1,Year(AddHours(GetCurrentDateTimeUtc(),10)),10,2,0,0),11,10)))


    ------------------------------
    Mike Hardie
    Developer
    ------------------------------



  • 3.  RE: Determine last Sunday in March and October

    Posted 05-07-2025 23:03
    Edited by Phaneendra Avatapalli 05-08-2025 00:21

    Hi Rudy,

    We've recently implemented this in a Digital Bot to handle callback availability across different times of the year, and I ran into the exact challenge you're describing - adjusting for daylight saving time without needing to manually update schedules or tables every time the clock shifts.

    To handle this, we use GetDayOfWeekOccurrence() to calculate whether DST is active (based on the first Sunday of October and April for us in Australia), and use that in our Architect flow logic to adjust the callback schedule accordingly.

    Below is the full example snippet we use to determine to enable callbacks between 11am–12pm Melbourne time, dynamically accounting for DST (AEDT/AEST in our case). Hope this helps.



    If(
        Hour(Flow.LocalDateTime) <  11,
        MakeDateTime(
            Year(Flow.LocalDateTime),
            Month(Flow.LocalDateTime),
            Day(Flow.LocalDateTime),
            If(
                Flow.LocalDateTime >= GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime)-1,10,1,2,0)
                And Flow.LocalDateTime < GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime),4,1,3,0),
                0,
                If(
                    Flow.LocalDateTime >= GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime),10,1,2,0),
                    0,
                    1
                )
            ),
            Minute(Flow.LocalDateTime),
            0
        ),
        If(
            (Day(AddDays(Flow.LocalDateTime, 1)) < Day(Flow.LocalDateTime)
             And DayOfWeek(AddDays(Flow.LocalDateTime, 1)) >= 2 
             And DayOfWeek(AddDays(Flow.LocalDateTime, 1)) <= 5),
            MakeDateTime(
                Year(AddDays(Flow.LocalDateTime, 1)),
                Month(AddDays(Flow.LocalDateTime, 1)),
                Day(AddDays(Flow.LocalDateTime, 1)),
                If(
                    AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1))-1,10,1,2,0)
                    And AddDays(Flow.LocalDateTime,1) < GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),4,1,3,0),
                    0,
                    If(
                        AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),10,1,2,0),
                        0,
                        1
                    )
                ),
                Minute(Flow.LocalDateTime),
                0
            ),
            If(
                (DayOfWeek(Flow.LocalDateTime) == 6 And Hour(Flow.LocalDateTime) >= 11)
                Or (DayOfWeek(Flow.LocalDateTime) == 6 And Day(AddDays(Flow.LocalDateTime, 3)) < Day(Flow.LocalDateTime)),
                MakeDateTime(
                    Year(AddDays(Flow.LocalDateTime, 3)),
                    Month(AddDays(Flow.LocalDateTime, 3)),
                    Day(AddDays(Flow.LocalDateTime, 3)),
                    If(
                        AddDays(Flow.LocalDateTime,3) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,3))-1,10,1,2,0)
                        And AddDays(Flow.LocalDateTime,3) < GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,3)),4,1,3,0),
                        0,
                        If(
                            AddDays(Flow.LocalDateTime,3) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,3)),10,1,2,0),
                            0,
                            1
                        )
                    ),
                    Minute(Flow.LocalDateTime),
                    0
                ),
                If(
                    (DayOfWeek(Flow.LocalDateTime) == 7)
                    Or (DayOfWeek(Flow.LocalDateTime) == 7 And Day(AddDays(Flow.LocalDateTime, 2)) < Day(Flow.LocalDateTime)),
                    MakeDateTime(
                        Year(AddDays(Flow.LocalDateTime, 2)),
                        Month(AddDays(Flow.LocalDateTime, 2)),
                        Day(AddDays(Flow.LocalDateTime, 2)),
                        If(
                            AddDays(Flow.LocalDateTime,2) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,2))-1,10,1,2,0)
                            And AddDays(Flow.LocalDateTime,2) < GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,2)),4,1,3,0),
                            0,
                            If(
                                AddDays(Flow.LocalDateTime,2) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,2)),10,1,2,0),
                                0,
                                1
                            )
                        ),
                        Minute(Flow.LocalDateTime),
                        0
                    ),
                    If(
                        (DayOfWeek(Flow.LocalDateTime) == 1)
                        Or (DayOfWeek(Flow.LocalDateTime) == 1 And Day(AddDays(Flow.LocalDateTime, 1)) < Day(Flow.LocalDateTime)),
                        MakeDateTime(
                            Year(AddDays(Flow.LocalDateTime, 1)),
                            Month(AddDays(Flow.LocalDateTime, 1)),
                            Day(AddDays(Flow.LocalDateTime, 1)),
                            If(
                                AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1))-1,10,1,2,0)
                                And AddDays(Flow.LocalDateTime,1) < GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),4,1,3,0),
                                0,
                                If(
                                    AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),10,1,2,0),
                                    0,
                                    1
                                )
                            ),
                            Minute(Flow.LocalDateTime),
                            0
                        ),
                        If(
                            Hour(Flow.LocalDateTime) >= 11,
                            MakeDateTime(
                                Year(AddDays(Flow.LocalDateTime, 1)),
                                Month(AddDays(Flow.LocalDateTime, 1)),
                                Day(AddDays(Flow.LocalDateTime, 1)),
                                If(
                                    AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1))-1,10,1,2,0)
                                    And AddDays(Flow.LocalDateTime,1) < GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),4,1,3,0),
                                    0,
                                    If(
                                        AddDays(Flow.LocalDateTime,1) >= GetDayOfWeekOccurrence(1,1,Year(AddDays(Flow.LocalDateTime,1)),10,1,2,0),
                                        0,
                                        1
                                    )
                                ),
                                Minute(Flow.LocalDateTime),
                                0
                            ),
                            MakeDateTime(
                                Year(Flow.LocalDateTime),
                                Month(Flow.LocalDateTime),
                                Day(Flow.LocalDateTime),
                                If(
                                    Flow.LocalDateTime >= GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime)-1,10,1,2,0)
                                    And Flow.LocalDateTime < GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime),4,1,3,0),
                                    0,
                                    If(
                                        Flow.LocalDateTime >= GetDayOfWeekOccurrence(1,1,Year(Flow.LocalDateTime),10,1,2,0),
                                        0,
                                        1
                                    )
                                ),
                                Minute(Flow.LocalDateTime),
                                0
                            )
                        )
                    )
                )
            )
        )
    )



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    Monash University
    Australia
    ------------------------------