CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
split record in MM/DD/YYYY format

 



casa3311
Deleted

Mar 7, 2001, 11:39 AM

Post #1 of 3 (394 views)
split record in MM/DD/YYYY format Can't Post

This may not be a beginner question, but I am less than 6 months new to Perl. I have a date that is coming from a form in MM/DD/YYYY format (ex. 3/7/2001) and I need to write it to a database in, for example, 03-MAR-2001 format. This date can also be null, so it might come in as MM/DD/YYYY in which case, I set the value to NULL otherwise I convert it to the proper format. I understand how to use the split command if you are separating the fields with a space, or a comma, or or any other character, but how do you split a record that is using the / as the field separator???



wickedxter
User

Mar 7, 2001, 4:58 PM

Post #2 of 3 (389 views)
Re: split record in MM/DD/YYYY format [In reply to] Can't Post

ok i got it

this is a sample code of what i did to split it

$date = "03/07/2001";
print "$date
";
print "
";
($m, $d, $y) = split(/\//,$date);
print "$m $d $y";






Jean
User


Mar 11, 2001, 12:48 AM

Post #3 of 3 (381 views)
Re: split record in MM/DD/YYYY format [In reply to] Can't Post

Just a remark:

"\n" can be used as a new line character.
Use
print "abcde\n";
instead
print "abcde
";




Jean Spector
QA Engineer @ Extent Technologies, Ltd.
mage@lycosmail.com

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives