Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting date format (mm/yyyy) ??

2 views
Skip to first unread message

chanr

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to
In the DB2 database, there is a date column which format is dd/mm/yyyy,
and i want to select a recordset with the format (dd/yyyy) of that column.

However, i can't find any explicit date types or date format that allowing
me
to do so. Thus, is there any simple way to retrieve the date from the
database
with usered defined format?

thx a lot

chanr


Jani Patanen

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to chanr

> to do so. Thus, is there any simple way to retrieve the date from the
> database
> with usered defined format?

select char(datecolumn,ISO)
returns date in ISO format (1999-11-21)

select char(datecolumn,USA)
return date in US format (11/22/1999)

See manual for more options (EUR etc.)

fatball

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to
However, i can't find any example that showing the date with the format
consisting of month and year only.
Can u should me the sample sql statement, please?

thx a lot!


Jani Patanen <Jani.Patan...@kolumbus.fi> wrote in message
news:3838F2A0...@kolumbus.fi...

Eddie White

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to
In article <81b2fv$4u...@imsp212.netvigator.com>,

DB2 does not a built-in date format that consists of mm/yyyy. However,
you can derive the date in that format by using a combination of
built-in functions, like so:

SELECT SUBSTR(CHAR(MY_DATE, ISO), 6, 2) CONCAT
'/' CONCAT
SUBSTR(CHAR(MY_DATE, ISO), 1, 4)
FROM CREATOR.TABLE;

This method assumes that the column you are selecting from has the DATE
data type, and that it is being returned to your program in ISO format;
that is, 'YYYY-MM-DD'.

Hope this helps.


Eddie White, Volvo IT North America
--
You can't be a nonconformist if you don't wear the
right uniform.
"And the Devil Will Drag You Under"
Jack L. Chalker


Sent via Deja.com http://www.deja.com/
Before you buy.

Blair Kenneth Adamache

unread,
Nov 22, 1999, 3:00:00 AM11/22/99
to
See the functions DAYOFYEAR and YEAR in the SQL Reference.

chanr wrote:

> In the DB2 database, there is a date column which format is dd/mm/yyyy,
> and i want to select a recordset with the format (dd/yyyy) of that column.
>
> However, i can't find any explicit date types or date format that allowing
> me

> to do so. Thus, is there any simple way to retrieve the date from the
> database
> with usered defined format?
>

> thx a lot
>
> chanr


fatball

unread,
Nov 23, 1999, 3:00:00 AM11/23/99
to
thx very much eddie

Eddie White <eddie...@hotmail.com> wrote in message
news:81biaf$us9$1...@nnrp1.deja.com...


> In article <81b2fv$4u...@imsp212.netvigator.com>,
> "fatball" <ch...@cimse.com> wrote:
> > However, i can't find any example that showing the date with the
> format
> > consisting of month and year only.
> > Can u should me the sample sql statement, please?
> >
> > thx a lot!
> >
> > Jani Patanen <Jani.Patan...@kolumbus.fi> wrote in message
> > news:3838F2A0...@kolumbus.fi...
> > >

> > > > to do so. Thus, is there any simple way to retrieve the date from
> the
> > > > database
> > > > with usered defined format?
> > >

0 new messages