X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B5472D1B50B for ; Wed, 17 Sep 2003 13:09:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 09485-01 for ; Wed, 17 Sep 2003 10:09:32 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 216F7D1B50C for ; Wed, 17 Sep 2003 10:09:29 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h8HD9Osl081551 for ; Wed, 17 Sep 2003 13:09:24 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h8HCosJr078724 for pgsql-sql@postgresql.org; Wed, 17 Sep 2003 12:50:54 GMT From: wireless200@yahoo.com (wireless) X-Newsgroups: comp.databases.postgresql.sql Subject: how to get decimal to date form Date: 17 Sep 2003 05:50:31 -0700 Organization: http://groups.google.com/ Lines: 16 Message-ID: <90446ee7.0309170450.2f16d9ef@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/165 X-Sequence-Number: 15143 In our postgre database is a decimal field with format YYMMDDhhmmss.9999999999 where the 9s are random digits. I'm trying to strip off just the YYMMDD and put it in date form. So far I came up with: SUBSTR(TO_CHAR(rec_num,99999999999),1,6) AS Date which returns YMMDD. For example where the rec_num is 30608124143.47069519725 the above functions return 30608. I tried wrapping another TO_CHAR around it to try to format it to a date but this seems like it's a bit much for this purpose. Any suggestions would be appreciated. -David