-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR]: Date Range Filters #604
Comments
Hello @Stilts15ak, There are two ways.
I think the first one is more interesting and easier to maintain. |
Could this also be achievable (in the short term) with using a formula and using relative dates (i.e. "Today", "This Week", etc.)? |
You can already use Luxon formulas https://rafaelgb.github.io/obsidian-db-folder/features/Formulas/ https://moment.github.io/luxon/api-docs/index.html#datetimetorelative
|
Thanks! I'll play around with it. |
Also I saw a problem with the formula. It should be refreshed after any change of the row. Will be fixed with the next version =) Commit b331dbd |
Yup! That's what I'm getting. I think this is a nice solution. Whether it's short or long term. However, it looks like DB will not filter a formula column. |
to allow the filters you need to persist the value (a toggle inside the column config) |
Not sure I understand. Can you elaborate further? |
Screen.Recording.2022-11-17.at.16.35.40.mov |
Thank you! Works like a charm now. Can I make a suggestion to where it says "Only persisted formulas could be searchable and sortable" to add "and filtered" as well? And perhaps include this in the documentation too? |
We can improve the documentation, of course. It's a young plugin and the changes are constant. So the documentation is hardly to maintain |
In the video example, Is it possible to use with the Created column (date from file created)? |
Yeah, it is possible |
All metadata fields need Try with |
Now it works, thanks Rafa! |
a new feature for calendar/calendar time will be added for the next version If you add an import { DateTime } from "luxon";
const valueToCalendarConverter = new Map<string, DateTime>([
["today", DateTime.local().startOf("day")],
["yesterday", DateTime.local().minus({ days: 1 }).startOf("day")],
["tomorrow", DateTime.local().plus({ days: 1 }).startOf("day")],
["thisweek", DateTime.local().startOf("week")],
["lastweek", DateTime.local().minus({ weeks: 1 }).startOf("week")],
["nextweek", DateTime.local().plus({ weeks: 1 }).startOf("week")],
["thismonth", DateTime.local().startOf("month")],
["lastmonth", DateTime.local().minus({ months: 1 }).startOf("month")],
["nextmonth", DateTime.local().plus({ months: 1 }).startOf("month")],
["thisyear", DateTime.local().startOf("year")],
["lastyear", DateTime.local().minus({ years: 1 }).startOf("year")],
["nextyear", DateTime.local().plus({ years: 1 }).startOf("year")],
["thisquarter", DateTime.local().startOf("quarter")],
["lastquarter", DateTime.local().minus({ quarters: 1 }).startOf("quarter")],
["nextquarter", DateTime.local().plus({ quarters: 1 }).startOf("quarter")],
]);
export default class FilterValuesMapper {
public static toCalendarValue(filterValue: string): DateTime {
if (filterValue.startsWith("@")) {
const potentialDate = valueToCalendarConverter.get(filterValue.slice(1).toLowerCase());
return potentialDate ? potentialDate : DateTime.local();
}
const potentialDate = DateTime.fromISO(filterValue);
return potentialDate.isValid ? potentialDate : DateTime.local();
}
} |
Contact Details
Stilts15ak@gmail.com
Present your request
It would be nice when filtering for dates if hard coded ranges could be implemented. (i.e. "Yesterday", "Today", "Tomorrow", "(#) Days", "This Week", "Next Week", "This Month", "Next Month", "This Year", "Future")
For which platform do you request this request??
Cross
The text was updated successfully, but these errors were encountered: