
TO_DATE() and PgSQL extension FROM_CHAR(). TO_CHAR() routine allow formating text output with a datetime values: SELECT TO_CHAR('now'::datetime, '"Now is: "HH24:MI:SS'); to_char ---------------- Now is: 21:04:10 FROM_CHAR() routine allow convert text to a datetime: SELECT FROM_CHAR('September 1999 10:20:30', 'FMMonth YYYY HH:MI:SS'); from_char ----------------------------- Wed Sep 01 10:20:30 1999 CEST TO_DATE() is equal with FROM_CHAR(), but output a Date only: SELECT TO_DATE('September 1999 10:20:30', 'FMMonth YYYY HH:MI:SS'); to_date ---------- 09-01-1999 In attache is compressed dir for the contrib. All is prepared, but I'am not sure if Makefile is good (probably yes). Comments & suggestions ? Thomas, thank you for your good advices. Karel ------------------------------------------------------------------------------ Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/
TO/FROM CHAR tests ~~~~~~~~~~~~~~~~~~ * rand_datetime The program 'rand_datetime' output a random datetime strings (with yaer range 0..9999), you can use this for datetime testing. You can usage this (example) for table filling. Usage: ./rand_datetime <randfile> <num> <prefix> <postfix> Example: ./rand_datetime /dev/urandom 2 "INSERT INTO tab VALUES('" "'::datetime);" INSERT INTO tab VALUES('Sat 27 Jul 13:08:57 19618'::datetime); INSERT INTO tab VALUES('Wed 25 Aug 20:31:50 27450'::datetime); * regress psql < regress.sql (all answers, must be TRUE, for Posgres datestyle) --> TO_DATE() is simular as FROM_CHAR(), but convert full datetime to date ==> needn't test (?).