Hi,
I need help to toggle through dates on a weekly basis to be fed into a script as inputs. The format should be: yyyy/mm/dd (start) yyyy/mm/dd (end), where end date is 7 days increments.
The date (start) would be input as an ARGV and would continue until current date.
I can check current date as follows:
is there any perl function that would toggle through by a week.
And if the Start Date is say Not Sunday, then the start date should be adjusted to the next nearest Sunday.
thank you
Subha
---------- Post updated at 06:57 PM ---------- Previous update was at 12:23 PM ----------
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
if ($#ARGV < 0)
{
die "Usage dates <input arg> : format is yyyy/mm/dd\n ";
exit (1);
}
my $start_date = $ARGV[0];
my $time = 0;
my $end_time = time;
print "Start Date: $start_date \n";
print "End Date: $end_time \n";
my @dates = split ('/', $start_date);
my $syyyy = $dates[0];
my $smm = $dates[1];
my $sdd = $dates[2];
$smm = $smm - 1;
$time = timelocal(0,0,0,$sdd,$smm,$syyyy);
print "Start time entered:", scalar(localtime($time)), "\n";
Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below.
Could you please help out to achieve solution through shell script..
File content:
... (2 Replies)
Hello folks,
I am looking for a Perl module or a program logic that gives the startdate and enddate of the last week..
Suppose say, assuming this week starts from Sunday to Saturday
If I execute the script in this week. I need to get the last week sunday's date.
Could anyone please... (1 Reply)
I have to increase the date by one week in an input when script is executed in solaris. I was able to acheive this using ksh script that is working in Linux enivironment, when i execute the same script in Solaris i am getting below error:
/var/tmp\n\r-> ./script.ksh
date: illegal option -- d... (3 Replies)
I have a weird requirement where I have to get the files from a FTP(Lets say FTP1) location and place it on my current FTP(Lets say FTP2) location. The issue is, these are daily files (in a pattern Sales_YYYYMMDD_report.csv) and are placed every day on FTP1 and my process usually runs on Monday(eg.... (2 Replies)
I have a directory of backup files.
named like this:
ldap.data.04-06-2012.tar
ldap.data.03-06-2012.tar
ldap.data.02-06-2012.tar
ldap.data.01-06-2012.tar
ldap.data.31-05-2012.tar
ldap.data.30-05-2012.tar
ldap.data.29-05-2012.tar
ldap.data.28-05-2012.tar
ldap.data.27-05-2012.tar... (6 Replies)
Hi guys,
First of all, I would like to say this is my first post in the unix.com forums. I am a beginner in PERL and have only started writing my first scripts.
With that out of the way, I have a question regarding the calculation of time dates in PERL.
I have two scalar variables with the... (1 Reply)
Hi,
Is there any way I can get the difference between two dates in terms of days?
I have used this method so far, but I cant format it in terms of days.
@a=&DateCalc($date1,$date2,0);
The o/p that I am getting is sort of like this:
+0:0:0:4:0:0:0
I just want to get 4 days as an o/p.... (1 Reply)
Hello friends,
I am looking for a script or method that can display all the dates between any 2 given dates.
Input:
Date 1
290109
Date 2
010209
Output:
300109
310109
Please help me. Thanks. :):confused: (2 Replies)
How to find the Day of the Week of the given Date using perl?
If I have a date in YYY--MM-DD format, how to find the DOW? Based on that, I need to find the following sunday.
Pls help. (5 Replies)
I need to create 12 variables, the first of which is the date of the first day of the current month (01/01/2006), and the remaining 11 are to equal each month after the current.
var1 = 01/01/2006
var2 = 02/01/2006
var3 = 03/01/2006
var4 = 04/01/2006
etc.
How can I easily do this is in... (7 Replies)