Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Computing Oracle date format from a date string

by hmerrill (Friar)
on Aug 23, 2002 at 19:30 UTC ( #192419=note: print w/replies, xml ) Need Help??


in reply to Computing Oracle date format from a date string

This is just an idea - completely untested as I don't currently have Oracle installed.
#!/usr/bin/perl -w use strict; #my $date = "2002-08-23 11:39:24"; #my $date = "Fri Aug 23 12:14:04 2002"; my $date = "Fri Aug 2 12:14:04 2002"; my $format; if ($date =~ /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/) { print "yes\n"; $format = "YYYY-MM-DD HH24:MI:SS"; } elsif ($date =~ /\w\w\w \w\w\w \d{1,2} \d\d:\d\d:\d\d \d\d\d\d/) { print "2nd one\n"; $format = "DY MON DD HH24:MI:SS YYYY"; } my $sql = qq{ INSERT INTO mytable (DATE_COL) VALUES (TO_DATE('?', '?') }; $sth = $dbh->prepare($sql) || die $dbh::errstr; $sth->execute($date, $format) || die $dbh::errstr; ### blah blah ###
Just an idea - hope it helps.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://192419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2019-05-26 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (153 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!