From 7f03c4b316790d4bb47850bda79b23f902b4d073 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Fri, 13 Dec 2024 14:57:18 +0100 Subject: [PATCH 1/2] fix: descriptions of some standard database functions after trying them out on my own, I saw some derivations from the actual behavior compared to the described behavior. --- guides/databases.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guides/databases.md b/guides/databases.md index 31e1514f7..3d308d5a2 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -375,10 +375,12 @@ This set of functions are by large the same as specified in OData: * `floor(x)` — rounds the input numeric parameter down to the nearest numeric value * `round(x)` — rounds the input numeric parameter to the nearest numeric value. The mid-point between two integers is rounded away from zero, i.e. 0.5 is rounded to 1 and ‑0.5 is rounded to -1. -* `year(x)` `month(x)`, `day(x)`, `hour(x)`, `minute(x)`, `second(x)`, `fractionalseconds(x)`, `time(x)`, `date(x)` — +* `year(x)` `month(x)`, `day(x)`, `hour(x)`, `minute(x)`, `second(x)` — returns parts of a datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` +* `time(x)`, `date(x)` - returns a string representing the `time` / `date` for a given `cds.DateTime` / `cds.Date` / `cds.Time` +* `fractionalseconds(x)` - returns a a `Decimal` representing the fractions of a second for a given `cds.Timestamp` * `maxdatetime(x)`, `mindatetime(x)` — return the maximum or minimum datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` -* `totalseconds(x)` — returns the total seconds of a datetime for a given `cds.DateTime` / `cds.Time` +* `totalseconds(x)` — returns the duration of the value in total seconds, including fractional seconds. The [OData spec](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_totalseconds) defines the input as EDM.Duration: `P12DT23H59M59.999999999999S` * `now()` — returns the current datetime * `min(x)` `max(x)` `sum(x)` `avg(x)` `count(x)`, `countdistinct(x)` — aggregate functions * `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy → [see Searching Data](../guides/providing-services#searching-data) From c05e64dbb82494c508f80d1afd8caeef7e551257 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Fri, 13 Dec 2024 15:04:17 +0100 Subject: [PATCH 2/2] Update databases.md --- guides/databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index 3d308d5a2..0ce7e0778 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -382,7 +382,7 @@ This set of functions are by large the same as specified in OData: * `maxdatetime(x)`, `mindatetime(x)` — return the maximum or minimum datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` * `totalseconds(x)` — returns the duration of the value in total seconds, including fractional seconds. The [OData spec](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_totalseconds) defines the input as EDM.Duration: `P12DT23H59M59.999999999999S` * `now()` — returns the current datetime -* `min(x)` `max(x)` `sum(x)` `avg(x)` `count(x)`, `countdistinct(x)` — aggregate functions +* `min(x)` `max(x)` `sum(x)` `average(x)` `count(x)`, `countdistinct(x)` — aggregate functions * `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy → [see Searching Data](../guides/providing-services#searching-data) * `session_context(v)` — with standard variable names → [see Session Variables](#session-variables) > 1 These functions work zero-based. E.g., `substring('abcdef', 1, 3)` returns 'bcd'