Sponsored Content
Top Forums Shell Programming and Scripting Perl script to toggle through dates by week Post 302365695 by Scrutinizer on Tuesday 27th of October 2009 08:10:27 PM
Old 10-27-2009
If you have GNU date you could perhaps also do it like this:
Code:
for i in {0..6}; do 
  date -d "091028 $i days " '+%Y/%m/%d'
done|xargs

2009/10/28 2009/10/29 2009/10/30 2009/10/31 2009/11/01 2009/11/02 2009/11/03

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help w/ Perl dates

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)
Discussion started by: ssmiths001
7 Replies

2. UNIX for Dummies Questions & Answers

How to find Day of the Week from the given date (Perl)?

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)
Discussion started by: deepakwins
5 Replies

3. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

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)
Discussion started by: frozensmilz
2 Replies

4. Shell Programming and Scripting

Perl difference between dates

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)
Discussion started by: King Nothing
1 Replies

5. Shell Programming and Scripting

Subtracting two dates in PERL

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)
Discussion started by: DiRNiS
1 Replies

6. Shell Programming and Scripting

Sorting dates in Perl

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)
Discussion started by: robsonde
6 Replies

7. Linux

Get all the files from a FTP location with previous week's dates in the file names using Linux

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)
Discussion started by: dhruuv369
2 Replies

8. Shell Programming and Scripting

Need Help:Shell Script for Solaris to change the dates in a file by one week

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)
Discussion started by: sriramanaramoju
3 Replies

9. Shell Programming and Scripting

Perl : Module to get the last week date and time

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)
Discussion started by: scriptscript
1 Replies

10. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

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)
Discussion started by: nani2019
2 Replies
DATEPERIOD.__CONSTRUCT(3)						 1						 DATEPERIOD.__CONSTRUCT(3)

DatePeriod::__construct - Creates a new DatePeriod object

SYNOPSIS
public DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, int $recurrences, [int $options]) DESCRIPTION
DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, [int $options]) DatePeriod::__con- struct (string $isostr, [int $options]) Creates a new DatePeriod object. PARAMETERS
o $start - The start date of the period. o $interval - The interval between recurrences within the period. o $recurrences - The number of recurrences. o $end - The end date of the period. o $isostr - An ISO 8601 repeating interval specification. o $options - Can be set to DatePeriod::EXCLUDE_START_DATE to exclude the start date from the set of recurring dates within the period. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.5.8 | | | | | | | $end type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | | 5.5.0 | | | | | | | $start type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DatePeriod example <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $recurrences = 4; $iso = 'R4/2012-07-01T00:00:00Z/P7D'; // All of these periods are equivalent. $period = new DatePeriod($start, $interval, $recurrences); $period = new DatePeriod($start, $interval, $end); $period = new DatePeriod($iso); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-01 2012-07-08 2012-07-15 2012-07-22 2012-07-29 Example #2 DatePeriod example with DatePeriod::EXCLUDE_START_DATE <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. // Note that, in this case, 2012-07-01 is not printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-08 2012-07-15 2012-07-22 2012-07-29 PHP Documentation Group DATEPERIOD.__CONSTRUCT(3)
All times are GMT -4. The time now is 10:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy