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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: OT-is there a way to do this in unix - date question

RE: OT-is there a way to do this in unix - date question

From: Mark W. Farnham <mwf_at_rsiz.com>
Date: Fri, 11 Feb 2005 17:28:24 -0500
Message-ID: <KNEIIDHFLNJDHOOCFCDKIEJMGAAA.mwf@rsiz.com>

#! /bin/sh
#  Copyleft (C) 2005  Rightsizing, Inc.
#
#  mm2mon -- wrapper for date to return 3 char month abbrev from numeric arg
#            with not even a hint of error checking.
#
#  Usage:    mm2mon <arg>
#

datedummy=`printf 2005%02d01 $1`
/usr/bin/date -d$datedummy +%b

This seems to work. The returns change based on your local language, though. If you have a version of the date command that does not take the -d argument this
will laugh at you, otherwise it should work fine.

A real shell person may know a cheaper way to format the string than invoking printf;
that part of my brain is off on tape somewhere. I think you have to give the -d option
a formatted string and it will figure out yymmdd and yyyymmdd. In your case any old
yyyy and dd will do.

If you want "like what you get with date +%b" then this is actually what you want.
>
> <ganstadba_at_hotmail.com> wrote:
> > without writing a whole series of ifs, given a number 1 - 12 give the
> > corresponding three letter month
> > like what you get with date +%b, but someone supplies you the digits
> > --
> > http://www.freelists.org/webpage/oracle-l

--
Peter Johnson
Humboldt State University
707-826-6122

--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l
Received on Fri Feb 11 2005 - 17:34:21 CST

Original text of this message

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