![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| convert date format YYYYMMDD to MM/DD/YYYY | nasirgondal | Shell Programming and Scripting | 7 | 4 Weeks Ago 06:06 AM |
| To convert multi format file to a readable ascii format | gaur.deepti | UNIX for Dummies Questions & Answers | 5 | 03-25-2008 11:03 AM |
| Convert UTF8 Format file to ANSI format | rajreddy | UNIX for Dummies Questions & Answers | 9 | 05-25-2007 05:26 AM |
| Convert UTF8 Format file to ANSI format | rajreddy | UNIX for Advanced & Expert Users | 1 | 05-24-2007 03:40 AM |
| how to convert from timestamp to date format in tcsh | umen | Shell Programming and Scripting | 2 | 11-22-2005 12:51 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
hi,
for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format. i checked the datecalc and other scripts but couldnt modify them to cater to my need The datecalc gives an output which i believe is the total days till that date, but i want to convert it in ccyyddd format for exmple: for todays date:092706 (mmddyy) i want to convert it to "2006270" (ccyyddd), and similary say for for any other date. thanks in advance!!! regards, Bhups |
| Forum Sponsor | ||
|
|
|
|||
|
try this
Code:
scp mm=`expr substr "$1" 1 2` dd=`expr substr "$1" 3 2` yyyy="20""`expr substr "$1" 5 2`" ddd=`cal_days $yyyy $mm $dd` echo "$yyyy$ddd" Code:
cal_days
#!/bin/perl
use Time::Local;
my $year=shift;
my $month=shift;
my $day=shift;
my $time = timelocal(0,0,23,$day,$month-1,$year-1900);
my $time1 = timelocal(0,0,0,1,0,$year-1900);
my $days = ( $time -$time1 ) / 86400;
printf("%.0f", $days);
Code:
$scp 092706 2006270 |