【问题标题】:PostgreSql + Date Format Convert YYYY-MM-DD to Day, Date Month YearPostgreSql + 日期格式 将 YYYY-MM-DD 转换为日、日月年
【发布时间】:2011-05-16 06:26:15
【问题描述】:

假设我将此格式存储在我的 postgre 数据库表中。现在我必须将此日期与包含不同格式日期的 texbox 值之一进行比较。

Database Date Format :: YYYY-MM-DD For example :: 2010-11-26

Text-Field Date Format :: Day, Month Date, Year :: Fri, Nov 26, 10

现在我试图比较这个值,但没有回应请建议。

    Select * from table_name where user_id=('11') 
and to_char(effective_date, $$$$$$$$)=trim('Fri, Nov 26, 10');

现在请建议我应该使用哪种格式来代替 $$$$$$$$ ???

谢谢!!!

【问题讨论】:

    标签: postgresql sql date-comparison


    【解决方案1】:
    SELECT 
      * 
    FROM 
      table_name 
    WHERE 
      user_id=('11') 
    AND 
      to_char(effective_date, 'Dy, Mon DD, YY') = trim('Fri, Nov 26, 10');
    

    【讨论】:

      【解决方案2】:

      应该这样做:to_char(effective_date, 'Dy, Mon DD, YY')

      顺便说一句:这一切都记录在手册中: http://www.postgresql.org/docs/current/static/functions-formatting.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-12
        • 2021-10-14
        • 2017-06-24
        相关资源
        最近更新 更多