What can we use in perl to retreive a date in the Locale format?
What can we use in perl to retreive a date in the Locale format?
Basically, I am retrieving some data from a database table via a stored proc. The data in the table is in English date format i.e dd/mm/yyyy. However, the perl scrip somehow converts this into mm/dd/yyyy.
I have used setlocale(LC_ALL, "english"); - but not doing the job.
It might have nothing to do with locale. If the date is actually stored as a string (in stead of raw or epoch seconds) then most likely the perl script is parsing it and reformatting the date to the authors requirements. If the script isn't too big post it.
I am executing a stored proc which brings back results from a table , sample of which is below and date is in 2nd columd which is of desired format i.e dd/mm/yyyy.
my $rfile = "/home/khanri/temp/KPI.csv";
my $inputFilePath = "/home/khanri/temp/";
my $filedate = `date +"%d%m%Y"`;
chomp $filedate;
my $tab_file = $inputFilePath . "anv.elp.run.report." .$filedate. ".txt";
if (not -e $tab_file) {
die ("$tab_file from has not arrived from Autosys, try later.\n");
}
$dbh = connect_to_db('ChopBlanks' => 1);
my $delete_old = 'truncate table batch_timings';
$sth = $dbh->prepare($delete_old);
$sth->execute or die("Deleting existing batch list failed \n");
system "$REPO/bin/DoBcpIn", 'batch_timings', $tab_file || die("Cannot BCP $tab_file\n");
my $process_kpi = 'exec build_kpi';
$sth = $dbh->prepare($process_kpi);
$sth->execute;
my $results = $sth->fetchall_arrayref;
$sth->finish();
open OUT, ">$rfile" or die "Can't open $rfile. $!\n";
print OUT join(",",@header) . "\n";
foreach my $rec ( @{$results} ) {
foreach my $column (@{$rec}) {
if (!$column) {
print OUT " ";
} else {
print OUT $column;
}
print OUT ",";
}
print OUT "\n";
}
Bookmarks