目前写过的最复杂的模板了,按文档名升序排列。
类似模板见【模板】汇总今天更新或指定日期范围的文档 · 语雀 (yuque.com)

注意:使用了updated和created字段,入围的文档至少在那个时间有创建过新块、改动过文字

上个月更新的文档

  1. .action{/* -------1.获取今年年份和上个月的月份数字------- */}
  2. .action{$this_year :=now | date "2006"}
  3. .action{$this_month :=now | date "01"}
  4. .action{$last_month := sub $this_month 1}
  5. .action{/* 处理月份为两位整数,小于10,则为0x */}
  6. .action{if gt $last_month 10}
  7. .action{/* if语句内如果想要给外部的全局变量赋值,需要用=而不是:=*/}
  8. .action{$last_month = $last_month}
  9. .action{else}
  10. .action{$last_month = nospace (cat "0" $last_month)}
  11. .action{end}
  12. .action{/* -------2.判断今年是否为闰年,得到这个月的最后一天------- */}
  13. .action{/* 2.1判断闰年,相当于if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 */}
  14. .action{$is_leap := any (all (empty (mod $this_year 4)) (not (empty (mod $this_year 100)))) (empty (mod $this_year 400))}
  15. .action{$MonthDict1 := dict "01" "31" "02" "28" "03" "31" "04" "30" "05" "31" "06" "30" "07" "31" "08" "31" "09" "30" "10" "31" "11" "30" "12" "31"}
  16. .action{$MonthDict2 := dict "01" "31" "02" "29" "03" "31" "04" "30" "05" "31" "06" "30" "07" "31" "08" "31" "09" "30" "10" "31" "11" "30" "12" "31"}
  17. .action{$Dicts := dict "true" $MonthDict2 "false" $MonthDict1}
  18. .action{$MonthDict := get $Dicts (toString $is_leap)}
  19. .action{/* 2.2得到这个月的最后一天 */}
  20. .action{$last_day := get $MonthDict (toString $last_month)}
  21. .action{$last_month_first :=nospace (cat $this_year "-" $last_month "-01")}
  22. .action{$last_month_last :=nospace (cat $this_year "-" $last_month "-" $last_day)}
  23. .action{/* 2.3格式化这个月的第一天和最后一天 */}
  24. .action{$from:= toDate "2006-01-02 15:04:05" (cat $last_month_first "00:00:00")}
  25. .action{$to := toDate "2006-01-02 15:04:05" (cat $last_month_last "23:59:59")}
  26. .action{/* -------3.获得上个月更新的所有笔记文档------- */}
  27. ## .action{$from | date "2006.01.02 Mon"} \~ .action{$to | date "2006.01.02 Mon"} 期间更新的笔记文档
  28. .action{$from:= $from | date "20060102150405"}
  29. .action{$to:= $to | date "20060102150405"}
  30. .action{/* 按文档名升序排列 */}
  31. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  32. .action{range $v := $blocks}
  33. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  34. .action{end}

某个月更新的文档

  1. .action{/* 设置想查询的年份和月份 */}
  2. .action{$this_year := 2021}
  3. .action{$this_month := 7}
  4. .action{/* -------1.获取今年年份和上个月的月份数字------- */}
  5. .action{/* 处理月份为两位整数,小于10,则为0x */}
  6. .action{if gt $this_month 10}
  7. .action{/* if语句内如果想要给外部的全局变量赋值,需要用=而不是:=*/}
  8. .action{$this_month = $this_month}
  9. .action{else}
  10. .action{$this_month = nospace (cat "0" $this_month)}
  11. .action{end}
  12. .action{/* -------2.判断今年是否为闰年,得到这个月的最后一天------- */}
  13. .action{/* 2.1判断闰年,相当于if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 */}
  14. .action{$is_leap := any (all (empty (mod $this_year 4)) (not (empty (mod $this_year 100)))) (empty (mod $this_year 400))}
  15. .action{$MonthDict1 := dict "01" "31" "02" "28" "03" "31" "04" "30" "05" "31" "06" "30" "07" "31" "08" "31" "09" "30" "10" "31" "11" "30" "12" "31"}
  16. .action{$MonthDict2 := dict "01" "31" "02" "29" "03" "31" "04" "30" "05" "31" "06" "30" "07" "31" "08" "31" "09" "30" "10" "31" "11" "30" "12" "31"}
  17. .action{$Dicts := dict "true" $MonthDict2 "false" $MonthDict1}
  18. .action{$MonthDict := get $Dicts (toString $is_leap)}
  19. .action{/* 2.2得到这个月的最后一天 */}
  20. .action{$last_day := get $MonthDict (toString $this_month)}
  21. .action{$this_month_first :=nospace (cat $this_year "-" $this_month "-01")}
  22. .action{$this_month_last :=nospace (cat $this_year "-" $this_month "-" $last_day)}
  23. .action{/* 2.3格式化这个月的第一天和最后一天 */}
  24. .action{$from:= toDate "2006-01-02 15:04:05" (cat $this_month_first "00:00:00")}
  25. .action{$to := toDate "2006-01-02 15:04:05" (cat $this_month_last "23:59:59")}
  26. .action{/* -------3.获得上个月更新的所有笔记文档------- */}
  27. ## .action{$from | date "2006.01.02 Mon"} \~ .action{$to | date "2006.01.02 Mon"} 期间更新的笔记文档
  28. .action{$from:= $from | date "20060102150405"}
  29. .action{$to:= $to | date "20060102150405"}
  30. .action{/* 按文档名升序排列 */}
  31. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  32. .action{range $v := $blocks}
  33. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  34. .action{end}

某一范围更新的文档

  1. .action{/* 在这里更新查询的起始时间*/}
  2. .action{$from:= toDate "2006-01-02 15:04:05" "2022-03-01 00:00:00"}
  3. .action{$to := toDate "2006-01-02 15:04:05" "2022-03-31 23:59:59"}
  4. ## .action{$from | date "2006.01.02 Mon"} \~ .action{$to | date "2006.01.02 Mon"} 期间更新的笔记文档
  5. .action{$from:= $from | date "20060102150405"}
  6. .action{$to:= $to | date "20060102150405"}
  7. .action{/* 按文档名升序排列 */}
  8. .action{$blocks :=queryBlocks "SELECT * FROM blocks WHERE id in (SELECT root_id FROM blocks WHERE root_id != '?' AND (created >= '?' AND created <= '?' OR updated >= '?' AND updated <= '?') ) order by HPath LIMIT -1" .id $from $to $from $to }
  9. .action{range $v := $blocks}
  10. - [.action{$v.HPath}](siyuan://blocks/.action{$v.ID})
  11. .action{end}