Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

LastDayWeek

LastDayWeek([dDate]) -> dFriday

Calculates the Friday associated with a date’s week.

LastDayWeekAdvPL
01 · OVERVIEW

Overview

The documented result is Friday; holidays are ignored. For Saturday it returns the previous day. It is therefore not a complete financial calendar despite the description’s last-business-day wording. Requires LIB 20210517 or newer and a TLPP-capable binary. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

LastDayWeek([dDate]) -> dFriday

Parameters

dDate
DateOptional

Date in the week; default Date().

Return value

Calculated Friday date.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed503()
    Local dFriday := LastDayWeek(SToD("20261031"))
    // Test Saturday; holidays are not considered.
    ConOut(DToS(dFriday))
Return Nil
Expected result

Expected result: 20261030. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • For due-date rules, integrate the appropriate calendar and test weekends and holidays.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. LastDayWeek. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha