gpt4 book ai didi

ruby-on-rails - 使用 Pluck 的 Rails 5 查询如何将 created_at 格式化为仅日期?

转载 作者:行者123 更新时间:2023-12-05 03:02:28 25 4
gpt4 key购买 nike

我有这个查询返回 created_at 日期时间行和一个值,我希望日期时间只是日期。我不知道如何在这种查询风格中使用任何日期时间格式选项。任何帮助表示赞赏。

@channels_counts_for_history_graph = Count.where(channel_id: 
current_channel).pluck("counts.created_at", "counts.followers")

最佳答案

你可以在sql命令中使用日期函数

@channels_counts_for_history_graph = Count.where(channel_id: 
current_channel).pluck("date(counts.created_at)", "counts.followers")

关于ruby-on-rails - 使用 Pluck 的 Rails 5 查询如何将 created_at 格式化为仅日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54734978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com