docs: missing documentation for TO_PREVIOUS_* datetime navigation functions

Open Beginner friendly
#3,235 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Quiet
Tech stack
sql
Domain
documentation

Research direction

Start by reading src/query/functions/src/scalars/timestamp/src/datetime.rs, especially the rounder_functions_helper registration in register_rounder_functions, and compare the existing grouped datetime-function documentation. Add a page under docs/en/sql-reference/20-sql-functions/05-datetime-functions/ covering all seven TO_PREVIOUS_* functions, their DATE or TIMESTAMP inputs, outputs, examples, and distinction from PREVIOUS_DAY.

Written by the indexing model from the issue text.

Description

documentation

Missing Documentation

The TO_PREVIOUS_* family of datetime navigation functions is implemented in Databend but has no documentation in the SQL reference.

Source Code

File: /workspace/databend/src/query/functions/src/scalars/timestamp/src/datetime.rs

Registered via rounder_functions_helper in register_rounder_functions:

  • to_previous_monday
  • to_previous_tuesday
  • to_previous_wednesday
  • to_previous_thursday
  • to_previous_friday
  • to_previous_saturday
  • to_previous_sunday

What They Do

Each function takes a DATE or TIMESTAMP value and returns the date of the most recent occurrence of the specified day of the week before the input date. For example, TO_PREVIOUS_MONDAY('2024-04-20') returns the date of the Monday before April 20, 2024.

These are distinct from PREVIOUS_DAY(date, 'monday') — they are fixed-day convenience functions with no second argument.

Suggested Doc Location

/docs/en/sql-reference/20-sql-functions/05-datetime-functions/

A single page covering all 7 functions (similar to how TO_START_OF_* functions are grouped) would work well, e.g. to-previous-day-of-week.md.

Dominant language
TypeScript
Stars
17
Forks
44
Avg merge
2d 7m
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databendlabs/databend-docs

All issues in databendlabs/databend-docs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.