Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Day

Day( <dData> ) --> nDia

Extracts the day of the month from a date.

DayAdvPL
01 · OVERVIEW

Overview

Day accepts a date and returns an integer from zero to 31. The reference documents zero for blank or invalid dates. This differs from CDow, which returns the weekday name. The example uses SToD to avoid day/month ambiguity and handles the transition beyond month end. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

Day( <dData> ) --> nDia

Parameters

dData
DateRequired

Date to extract the day from.

Return value

Integer from 0 to 31 according to the date.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed322()
    Local dReference := SToD("20261031")
    // Adding a day changes the month before day extraction.
    ConOut(cValToChar(Day(dReference)))
    ConOut(cValToChar(Day(dReference + 1)))
Return Nil
Expected result

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

BEST PRACTICES
  • Validate dates before due-date rules. A day number alone identifies neither a date nor a full interval.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Day. TDN. Accessed on 2026-10-26.
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