The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings

Snippet Library

Decode an snmp timestamp textual convention in postgreql

Sample Code (HOWTO)
Unix Admin
GNU General Public License

Expression aisément transformable en fonction permettant de décoder un timestamp au format RFC 2579

Versions Of This Snippet:

Snippet ID Download Version Date Posted Author Delete
51.O2017-01-19 18:21Jean-marie Kubek Delete

Download a raw-text version of this code by clicking on “Download Version”

Latest Snippet Version: 1.O

-- entrée : une chaine de caractère convertible en chaîne d'octets (bytea) par exemple : '\x07e10113122b09082b0100'::bytea
--sortie : timestamp 
select concat((get_byte(v,0)<<8) + get_byte(v,1),'-',get_byte(v,2),'-',get_byte(v,3),' ', get_byte(v,4),':',get_byte(v,5),':',get_byte(v,6),'.',get_byte(v,7),' ',chr(get_byte(v,8)),get_byte(v,9),':',get_byte(v,10))::timestamp with time zone from (select '\x07e10113122b09082b0100'::bytea  as v)Exp;

Add a new version

You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others.