Hello,
I am trying to get the last element from a list, using Bases.
I have this code:
```base
formulas:
date_len: len(date)
views:
- type: table
name: Table
filters:
and:
- date_on_or_after(slice(date[0], 2, 12), date_modify(now(), "-4 day"))
- date_on_or_before(slice(date[0], 2, 12), now())
- not(contains(property.tags, "entity"))
order:
- date
- formula.date_len
columnSize:
file.name: 700
property.tags: 500
formula.date_len: 215
sort:
- column: formula.date_len
direction: DESC
- column: property.date
direction: DESC
```
And I get the following:
So, I tried using “date_len” to get the last index, but I get blank:
I tried with this code:
```base
formulas:
date_len: len(date)
date_last: date[len(date)-1]
views:
- type: table
name: Table
filters:
and:
- date_on_or_after(slice(date[0], 2, 12), date_modify(now(), "-4 day"))
- date_on_or_before(slice(date[0], 2, 12), now())
- not(contains(property.tags, "entity"))
order:
- date
- formula.date_len
- formula.date
columnSize:
file.name: 700
property.tags: 500
formula.date_len: 215
sort:
- column: formula.date_len
direction: DESC
- column: property.date
direction: DESC
```
Also, with:
formulas:
date_len: len(date)
date_last: date[date_len-1]
formulas:
date_last: "date[len(date)-1]"
formulas:
date_last: date[len(date)-1]
As small test, this works:
formulas:
date_last: date[0]
… and to remove the [[]]
and convert to a date, I used slice(date[0], 2, 12)
. I was not able to convert Wikilinks to a proper datetime
object.
Any ideas what I could be doing wrong?
Thanks!
My system information:
SYSTEM INFO:
Obsidian version: v1.9.0
Installer version: v1.8.10
Operating system: Windows 11 Pro 10.0.26100
Login status: logged in
Language: en
Catalyst license: insider
Insider build toggle: on
Live preview: on
Base theme: dark
Community theme: none
Snippets enabled: 4
Restricted mode: off
Plugins installed: 15
Plugins enabled: 11
1: Enhancing Export v1.10.9
2: Natural Language Dates v0.6.2
3: Settings Search v1.3.10
4: Tag Wrangler v0.6.4
5: Plugin Update Tracker v1.6.2
6: Tasks v7.19.1
7: Templater v2.11.1
8: Text Format v3.1.0
9: Calendar v1.5.10
10: Git v2.33.0
11: Homepage v4.2.1