PostgreSql +日期格式将YYYY-MM-DD转换为日期,日期月份年份

时间:2022-10-29 13:01:44

Suppose I am storing this format in my postgre database table. Now I have to compare this date with one of the texbox value contain date in different format.

假设我将这种格式存储在我的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

Now I have tried to compare this value but no response Plz suggest.

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

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

Now Plz suggest which format should I use in place of $$$$$$$$ ???

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

Thanks !!!

2 个解决方案

#1


13  

SELECT 
  * 
FROM 
  table_name 
WHERE 
  user_id=('11') 
AND 
  to_char(effective_date, 'Dy, Mon DD, YY') = trim('Fri, Nov 26, 10');

#2


5  

This should do it: to_char(effective_date, 'Dy, Mon DD, YY')

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

Btw: this is all documented in the manual: http://www.postgresql.org/docs/current/static/functions-formatting.html

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

#1


13  

SELECT 
  * 
FROM 
  table_name 
WHERE 
  user_id=('11') 
AND 
  to_char(effective_date, 'Dy, Mon DD, YY') = trim('Fri, Nov 26, 10');

#2


5  

This should do it: to_char(effective_date, 'Dy, Mon DD, YY')

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

Btw: this is all documented in the manual: http://www.postgresql.org/docs/current/static/functions-formatting.html

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