Skip to content

Use Obsidian Templater date module to display weeks passed since specific date? #459

Answered by slaughtr
NHeoShadow asked this question in Help
Discussion options

You must be logged in to vote

Using moment you can do this pretty easily

<%* 
var x = moment('2021-12-10').diff('2021-12-19', 'weeks') 
x = Math.abs(x)
tR += x
%>

Math.abs() isn't necessary if your first date is ahead of your second IE you're looking back, but in the above example you get -1 - if you actually want to show negative weeks and positive, remove the Math.abs()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@NHeoShadow
Comment options

@SolientArt
Comment options

Answer selected by NHeoShadow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants