20061107

How-to output RFC822 dates in Oracle PL/SQL

There's a little to_char string that can help you in outputting RFC822 dates (the format required for RSS dates) in Oracle PL/SQL.


to_char(sysdate-(1/24),'Dy, DD Mon YYYY hh24:mi:ss','NLS_DATE_LANGUAGE=AMERICAN')||' GMT'


Beware that I've to take one hour off, because I'm in Spain, GMT+1, if you are in a different time zone you only have to add or substract the difference between GMT and your time zone.

I hope you will enjoy.

2 comentarios:

Anónimo dijo...

tt
i que oo passa amb l'horari d'estiu?
ksum l'ou, ja em veig tocant l'ed_get ;-)

Anónimo dijo...

c'est moi aussi
e voila


function dateUTC(data date) return date as
v_data date;
begin
if substr(dbtimezone,1,1)='+' then
return sysdate-to_number(substr(dbtimezone,2,2))/24;
else
return sysdate+to_number(substr(dbtimezone,2,2))/24;
end if;
end dateUTC;

function toRFC822(data date) return varchar2 as
begin
if substr(dbtimezone,1,1)='+' then
return to_char( sysdate-to_number(substr(dbtimezone,2,2))/24,'Dy, DD Mon YYYY HH24:MI:SS','NLS_DATE_LANGUAGE=AMERICAN')||' GMT';
else
return to_char( sysdate+to_number(substr(dbtimezone,2,2))/24,'Dy, DD Mon YYYY HH24:MI:SS','NLS_DATE_LANGUAGE=AMERICAN')||' GMT';
end if;
end toRFC822;