You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a seeded random number based on either a `number` or a `text`. Repeated calls to `srandom()` with the same seed, gives the same sequence of random numbers. This is useful in a query when combined with sorting a list on this sequence, and then doing a `LIMIT` on that sequence, to get a given set of random items for that seed.
278
+
279
+
In other words, if used with a date, you can sort your list/quotes/... and get a random element from that list, and it'll change when your date string changes. This way you can get a random item each day, each hour, etc based on what you use as the seed.
Copy file name to clipboardexpand all lines: docs/docs/resources/examples.md
+15
Original file line number
Diff line number
Diff line change
@@ -83,3 +83,18 @@ List all files which have a date in their title (of the form `yyyy-mm-dd`), and
83
83
=== "Output"
84
84
- [2021-08-07](#): August 07, 2021
85
85
- [2020-08-10](#): August 10, 2020
86
+
87
+
---
88
+
89
+
Get three random links from your vault, which changes every day, but are consistent throughout the day. Similar queries can also be used to get random quotes, or other random items to your liking.
90
+
91
+
=== "Query"
92
+
```sql
93
+
LIST
94
+
FLATTEN srandom(dateformat(date(today), "yyyy-MM-dd")) as randomValue
95
+
SORT randomValue
96
+
LIMIT3
97
+
```
98
+
=== "Output"
99
+
100
+
Three random links from your vault, where on any given day the three links are consistently the same. The only thing capable of changing it, is changing the source list from where you're pulling the random items.
0 commit comments