ProScreener/proscreener

DATEFORMAT

DATEFORMAT is a ProScreener display modifier that renders a numeric YYYYMMDD value as a readable date in a SCREENER results column, such as 2 Dec 2022.

Syntax

probuilder
SCREENER(value AS "Column name" DATEFORMAT)

How it works

A SCREENER results column normally shows the raw numeric value of whatever expression it was given. When the expression encodes a date, that raw number is hard to read. Placing DATEFORMAT after the AS "Column name" clause tells the results table to interpret the number as a date in YYYYMMDD form and render it in a human-readable format.

The modifier changes presentation only. The underlying value stays numeric, so sorting the column still works on the number itself. Because YYYYMMDD values sort in the same order as the dates they represent, chronological sorting behaves as expected.

DATEFORMAT pairs naturally with the date and time constants of the language. Values such as Today, Yesterday, and OpenDate already return numbers in YYYYMMDD form, so they can be passed straight into a formatted column. Any other numeric expression is accepted, but only values that encode a valid calendar date produce meaningful output.

Examples

Example 1, Displaying a fixed numeric date (ProScreener)

probuilder
// A numeric value in YYYYMMDD form, here 2 December 2022
number = 20221202
SCREENER(number AS "Formatted Date" DATEFORMAT)

The column labelled Formatted Date shows 2 Dec 2022 instead of the raw number 20221202. This is the canonical example from the official reference.

Example 2, Showing the bar date for oversold stocks (ProScreener)

probuilder
// List oversold instruments together with the date of the scanned bar
myRSI = RSI[14](close)
oversold = myRSI < 30
barDate = OpenDate
SCREENER[oversold](barDate AS "Bar date" DATEFORMAT)

Each matching instrument appears with the opening date of its most recent bar rendered as a readable date, which is useful when scanning markets whose last session may differ.

Example 3, Attaching the scan date to new highs (ProScreener)

probuilder
// Stamp each result with the date the scan was run
newHigh = close >= Highest[250](close)
SCREENER[newHigh](Today AS "Scan date" DATEFORMAT)

Instruments making a 250-bar closing high are listed with the current date as a formatted column, which helps when exporting or archiving screener results.

Common errors and gotchas

  • Value must encode YYYYMMDD. DATEFORMAT does not convert timestamps, day counts, or arbitrary numbers into dates. A value like 1670000000 (a Unix-style timestamp) or 45123 renders as a nonsense date. Build the value as year times 10000 plus month times 100 plus day, or use constants such as Today that already return that form.
  • No validation of the date. The modifier formats whatever digits it receives. A value like 20221399 (month 13, day 99) is not rejected at compile time and produces meaningless output. Verify the expression that feeds the column.
  • One format modifier per column. DATEFORMAT cannot be combined with NUMBERFORMAT, PERCENTFORMAT, or STRINGFORMAT on the same column. Pick the single modifier that matches the data.
  • ProScreener only. The keyword compiles nowhere else. In an indicator, date display is handled differently, typically with DRAWTEXT style output, not with DATEFORMAT.
  • NUMBERFORMAT, abbreviates large numeric values in a screener column.
  • PERCENTFORMAT, renders a screener column value as a percentage.
  • STRINGFORMAT, shows a screener column value exactly as stored.
  • SCREENER, defines the filter condition and result column of a screener.
  • TIMEFRAME (PS), sets the timeframe used by subsequent screener code.
  • Today, the current date in YYYYMMDD form.
  • Yesterday, the previous calendar date in YYYYMMDD form.
  • OpenDate, the opening date of a bar in YYYYMMDD form.