Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Coolest way to decode YYYYMMDD?

by erix (Parson)
on Jun 03, 2013 at 06:53 UTC ( #1036677=note: print w/replies, xml ) Need Help??

in reply to Coolest way to decode YYYYMMDD?

Why all the contortions? Keep it simple and talk to your database:

$ echo "select to_char(to_date('19830501?','YYYYMMDD'), 'FMMon FMdd, y +yyy?')" \ | perl -MDBI -ne ' print DBI->connect("dbi:Pg:")->selectall_arrayref($_)->[0]->[0], + "\n"; '; May 1, 1983?


P.S. (Looks I am the first one to spot the terminal question mark in your example? Does that get me Mega-XP too?)

Replies are listed 'Best First'.
Re^2: Coolest way to decode YYYYMMDD?
by hdb (Monsignor) on Jun 03, 2013 at 16:56 UTC

    If DateTime is not a requirement, and short month names are ok (difficult to say with "May" as the only example), then I offer this:

    printf('"%s %d,%d?"',substr(gmtime(34e6*('19830501'=~/(....)(..)(..)/) +[1]),4,3),$3,$1);
Re^2: Coolest way to decode YYYYMMDD?
by Your Mother (Bishop) on Jun 03, 2013 at 13:48 UTC

    The question mark is ambiguous in this context but it's proper English style see below. Liked your direct approach. :P

      it's proper English style.

      Actually... No, it's not. While there is some (little) conflict over when/whether periods & commas should go inside, all authorities agree that "question marks and exclamation points follow [i.e. go outside] closing quotation marks unless they belong within the quoted matter." (Chicago Manual)

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

        While I will take issue with Chicago being il capo di tutti authorities, I will take the correction to season the crow of my mistakenly conflating commas and periods with question marks and bangs.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036677]
and the monks are chillaxin'...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2018-05-28 04:23 GMT
Find Nodes?
    Voting Booth?