Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

How to change thhe date format during imports?

Quote Reply
How to change thhe date format during imports?
I have my database in Access and am unable to get it sucessfully in to Links SQL. This upsetting is going on since three months.

Can some one tell me how to get 01.01.99 to 1999-01-01 in the unix format.

I checked the Resources and also the other forums. But they all gives support on new date to unixdate. So what I need is

if ($table eq 'Links') {
if ($record{'Add_date'} !~ /^\d*$/) {
$record{'Add_date'} = &import_to_unixdate ($record{'Add_date'}) | | ($record{'Add_date'});
}
}

sub import_to_unixdate

my $unixdate = ($record{'Add_date'}) = shift;
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $unixdate;
$year = $year + 1900; $mon++;
($mon < 10) and ($mon = "0" . int $mon); ($day < 10) and ($day = "0" . int $day);
return "$year-$mon-$day";
}


Will this work? How do I pass the variable ($record{'Add_date'}) to the $unixdate and change the format as :

(Access date) 01.01.99 >> 1999-01-01 (Unix date)














[This message has been edited by rajani (edited October 30, 1999).]
Quote Reply
Re: How to change thhe date format during imports? In reply to
Hello Alex!

This text area box of the forum is a bit small to write the codes. So its difficult. May be a bit bigger will be nice, if possible.

------------------
rajani











Quote Reply
Re: How to change thhe date format during imports? In reply to
Something like:

Code:
sub convert_date {
my $in_date = shift;
($day, $mon, $year) = split /\./, $in_date;
($year > 70) ? ($year = "19$year") : ($year = "20$year");
return "$year-$mon-$day";
}

should work. One Y2K note, I'm assuming the date in the year 2000 will be 01.01.00. Also, I'm assuming that it is dd.mm.yy.

Then just do:

$record{'Add_Date'} = &convert_date($record{'Add_Date'});

to convert the date.

Hope that helps,

Alex
Quote Reply
Re: How to change thhe date format during imports? In reply to
Many Thanks Alex.

------------------
rajani