根据生日日期进行排序,而无需考虑日期的年份

发布于 2025-01-19 11:41:51 字数 460 浏览 0 评论 0原文

我试图根据生日日期对工作表进行排序,最近的生日应该放在第一行,最后一个放在最后,依此类推,要做到这一点,它应该只考虑日期和月份,而不考虑年份排序,所有这些都是通过使用查询功能来实现的,因为数据是从另一张表中查询的。

我尝试过使用以下内容

=SORT(QUERY('Sheet1'!A2:Q, "SELECT * "),6,FALSE)

,但它不起作用,我还尝试通过谷歌表格自定义日期和时间格式化数据以仅显示日期和月份,并且仍然只隐藏年份,但排序仍然考虑年份,如果我应用过滤器进行排序是行不通的,因为它是一个查询函数。有什么建议吗?

工作表链接

I am trying to sort sheet according to birthday date, the closest birthday should go in first row, and the last go to the end and so on, to do this it should only consider the day and month without taking into account the year for the sorting, all this by using the query function since the data is being queried from another sheet.

I have tried using the following

=SORT(QUERY('Sheet1'!A2:Q, "SELECT * "),6,FALSE)

but it is not working, i have also tried formatting the data to show only day and month via google sheets custom date and time, and still only hides the year but for sorting still considers the year, and if I aply a filter for sorting it will not work since it is a query function. Any suggestion?

Link to sheet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

他不在意 2025-01-26 11:41:51

尝试:

=QUERY(SORT(Sheet1!A2:Q27, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null", 0)

在此处输入图像描述


更新:

=ARRAYFORMULA(ARRAY_CONSTRAIN({
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 >= date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0);
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 < date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0)}, 9^9, 17))

在此处输入图像描述

try:

=QUERY(SORT(Sheet1!A2:Q27, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null", 0)

enter image description here


update:

=ARRAYFORMULA(ARRAY_CONSTRAIN({
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 >= date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0);
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 < date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0)}, 9^9, 17))

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文