pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yasir Malik <ymalik@cs.stevens-tech.edu>
To: Dmitry Tkach <dmitry@openratings.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Datatype conversion help
Date: Wed, 9 Jul 2003 14:55:04 -0400 (EDT)
Message-ID: <Pine.NEB.4.53.0307091454250.9806@black-label.cs.stevens-tech.edu> (raw)
In-Reply-To: <3F0C9C84.5000808@openratings.com>
References: <Pine.SGI.4.51.0307081604030.4185018@guinness.cs.stevens-tech.edu>
	<1057695693.24179.0.camel@localhost>
	<Pine.SGI.4.51.0307081625220.4193960@guinness.cs.stevens-tech.edu>
	<3F0C99E5.4090205@openratings.com>
	<Pine.NEB.4.53.0307091445210.9780@black-label.cs.stevens-tech.edu>
	<3F0C9C84.5000808@openratings.com>

I will surely use your suggestion in my future programs.
Thanks,
Yasir

On Wed, 9 Jul 2003, Dmitry Tkach wrote:

> Date: Wed, 09 Jul 2003 18:51:48 -0400
> From: Dmitry Tkach <dmitry@openratings.com>
> To: Yasir Malik <ymalik@cs.stevens-tech.edu>
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Datatype conversion help
>
> Yasir Malik wrote:
>
> >I used trim and here's what I came up with:
> >to_date(trim(to_char(yr, '9999') || trim(to_char(mn, '00')) ||
> >trim(to_char(dy, '00'))), 'YYYYMMDD')
> >
> >Apparently to_char adds a space to the charecter you are casting.
> >
> >
> I know :-)
> And lpad doesn't - that's why I suggested it :-)
>
> Dima
>
> >
> >On Wed, 9 Jul 2003, Dmitry Tkach wrote:
> >
> >
> >
> >>Date: Wed, 09 Jul 2003 18:40:37 -0400
> >>From: Dmitry Tkach <dmitry@openratings.com>
> >>To: Yasir Malik <ymalik@cs.stevens-tech.edu>
> >>Cc: pgsql-sql@postgresql.org
> >>Subject: Re: [SQL] Datatype conversion help
> >>
> >>What about lpad?
> >>
> >>select lpad (7, 2, 0) || '-' || lpad (9, 2, '0') || '-2003';
> >>  ?column?
> >>------------
> >> 07-09-2003
> >>(1 row)
> >>
> >>
> >>I hope, it helps...
> >>
> >>Dima
> >>
> >>Yasir Malik wrote:
> >>
> >>
> >>
> >>>Thank you so much!  But my problem is that when I do
> >>>to_char(mn, '00') || '-' || to_char(dy, '00') || '-' || to_char(yr,
> >>>'9999')
> >>>
> >>>where mn, dy, and yr are ints, is that the output has a space after the
> >>>the dash.  For example, I get
> >>>07- 25- 1994
> >>>
> >>>instead of what I want:
> >>>07-25-1994
> >>>
> >>>Thanks,
> >>>Yasir
> >>>
> >>>On Tue, 8 Jul 2003, Richard Rowell wrote:
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>Date: 08 Jul 2003 15:21:33 -0500
> >>>>From: Richard Rowell <richard@bowmansystems.com>
> >>>>To: Yasir Malik <ymalik@cs.stevens-tech.edu>
> >>>>Subject: Re: [SQL] Datatype conversion help
> >>>>
> >>>>On Tue, 2003-07-08 at 15:07, Yasir Malik wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>I've tried to_char(in_val, '99'), and that returns a string that is two
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>select to_char(9,'00');
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>---------------------------(end of broadcast)---------------------------
> >>>TIP 8: explain analyze is your friend
> >>>
> >>>
> >>>
> >>>
> >>
> >>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>



view thread (13+ messages)  latest in thread

Message-ID: <Pine.NEB.4.53.0307091454250.9806@black-label.cs.stevens-tech.edu>
Permalink:  ../Pine.NEB.4.53.0307091454250.9806@black-label.cs.stevens-tech.edu/
Also on:    postgresql.org/message-id/Pine.NEB.4.53.0307091454250.9806@black-label.cs.stevens-tech.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ymalik@cs.stevens-tech.edu, dmitry@openratings.com
  Subject: Re: Datatype conversion help
  In-Reply-To: <Pine.NEB.4.53.0307091454250.9806@black-label.cs.stevens-tech.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox