Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Date format for 8/4/97, plus TRUNC('ww') question

Re: Date format for 8/4/97, plus TRUNC('ww') question

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1997/08/05
Message-ID: <870801762.22222@dejanews.com>#1/1

In article <5s622l$3pl$1_at_grandprime.binc.net>,   kevin_at_cpm.com (Kevin Bourrillion) wrote:
>
> 1. Why does the date format 'fmMM' work as expected (yielding '8' today),
> but 'fmDD' does not (yielding '04')? Do I really have to do THIS to
> get the date to come out nicely?
>
> TO_CHAR(some_date, 'Dy fmMM/') || LTRIM(TO_CHAR(some_date, 'DD/YY'), '0')

Try: select to_char(sysdate,'Dy fmMM/DD/YY') from dual; I get the following: Tue 8/5/97

You must have been using 'fmMM/fmDD...'. When you use fm twice in a string, the second 'fm' toggles the effect of the first, disabling the effect of the first 'fm'.

> 2. The reference book says TRUNC(some_date, 'ww') should always give a
> Monday. Mine always seems to give a Wednesday. Huh?

I tried Trunc(to_date('01-JAN-97'),'ww') for various dates, and the date returned was always a Wednesday for 1997 dates, but was Monday for 1996 dates, and Thursday for 1998 dates. It makes sense once you see that you always get the day of the week of Jan. 1 of whatever year you are entering.

Regards,
Steve Cosner
http://members.aol.com/stevec5088

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
Received on Tue Aug 05 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US