Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Splitting week start date and end date based on custom period start dates Post 303043750 by nani2019 on Wednesday 5th of February 2020 11:04:48 AM
Old 02-05-2020
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..

Code:
 File content:

period_start_date	period_end_date	period_code
2020-01-01	2020-01-15	P1
2020-01-05	2020-01-19	P2
2020-01-16	2020-01-31	P1
2020-01-20	2020-02-04	P2
2020-02-01	2020-02-15	P1
2020-02-05	2020-02-19	P2
2020-02-16	2020-02-29	P1
2020-02-20	2020-03-04	P2
2020-03-01	2020-03-15	P1
2020-03-05	2020-03-19	P2
2020-03-16	2020-03-31	P1
2020-03-20	2020-04-04	P2
2020-04-01	2020-04-15	P1
2020-04-05	2020-04-19	P2
2020-04-16	2020-04-30	P1
2020-04-20	2020-05-04	P2
2020-05-01	2020-05-15	P1
2020-05-05	2020-05-19	P2
2020-05-16	2020-05-31	P1
2020-05-20	2020-06-04	P2

Code:
Expected Result for  					
1) period start date 	2020-01-01	Period End date	2020-01-15	Period code 	 P1        
2) period start date 	2020-01-05	Period End date	2020-01-19	Period code 	 P2     
3) period start date 	2020-01-16	Period End date	2020-01-31	Period code 	 P1     
4) period start date 	2020-01-20	Period End date	2020-02-04	Period code 	 P2

Code:
week Start Date	Week End Date	Period strat Date	Period end Date	Period code
2020-01-01	2020-01-05	2020-01-01	2020-01-15	P1
2020-01-06	2020-01-12	2020-01-01	2020-01-15	P1
2020-01-13	2020-01-15	2020-01-01	2020-01-15	P1
2020-01-05	2020-01-05	2020-01-05	2020-01-19	P2
2020-01-06	2020-01-12	2020-01-05	2020-01-19	P2
2020-01-13	2020-01-19	2020-01-05	2020-01-19	P2
2020-01-16	2020-01-19	2020-01-16	2020-01-31	P1
2020-01-20	2020-01-26	2020-01-16	2020-01-31	P1
2020-01-27	2020-01-31	2020-01-16	2020-01-31	P1
2020-01-20	2020-01-26	2020-01-20	2020-02-04	P2
2020-01-27	2020-02-02	2020-01-20	2020-02-04	P2
2020-02-03	2020-02-04	2020-01-20	2020-02-04	P2


Last edited by nani2019; 02-05-2020 at 12:05 PM.. Reason: none
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare Start date and End date...

Hi All, I have problem in my file. It has two date variable. There are 2 variables which has the values as below 1. START_MONTH = “Date(YYYYMM) format” Ex: 201008 2. END_MONTH = “Date(YYYYMM) format” Ex: 201105 The end date should be greater than start date. Now we... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

2. Shell Programming and Scripting

Need to capture all dates between start date and End date.

Hi All, I enter Start date and end date as parameters. I need to capture dates between start date and end date. Please let me know if you have any idea the same. Thanks in advance. Nagaraja Akkivalli. (5 Replies)
Discussion started by: Nagaraja Akkiva
5 Replies

3. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

4. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

5. Shell Programming and Scripting

Getting the Start, End time and duration using date command

Oracle Enterprise Linux We want to track how long a process takes to complete its execution. This is what we want in the schell script Before the process is started , get the time with date, hours and minutes execute the process After the process has ended , get the time with date,... (5 Replies)
Discussion started by: omega3
5 Replies

6. Shell Programming and Scripting

Get the lines from logfile within start and end date

Hi guys, I am having the below logfile,date in yyyy-mm-dd 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-03 *some content* 2013-08-05 *some content* from the above logfile i need to get the lines between the two timestamps,if i give... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

7. UNIX for Dummies Questions & Answers

Print start date to end date, given $1 & $2 in ksh

Dear all, I have an user passing 2 parameter 31/03/2015 and 02/04/2015 to a ksh script. How to print the start date to end date. Expected output is : 31/03/2015 01/04/2015 02/04/2015 Note : 1. Im using aix and ksh 2. I have tried to convert the given input into a date, didnt... (0 Replies)
Discussion started by: mr.rajaravi
0 Replies
Oxford::Calendar(3pm)					User Contributed Perl Documentation				     Oxford::Calendar(3pm)

NAME
Oxford::Calendar - University of Oxford calendar conversion routines SYNOPSIS
use 5.10.0; use Oxford::Calendar; use Date::Calc; say "Today is " . Oxford::Calendar::ToOx(reverse Date::Calc::Today); DESCRIPTION
This module converts University of Oxford dates (Oxford academic dates) to and from Real World dates, and provides information on Terms of the University. The Terms of the University are defined by the Regulations on the number and lengths of terms, available online from http://www.admin.ox.ac.uk/examregs/03-00_REGULATIONS_ON_THE_NUMBER_AND_LENGTH_OF_TERMS.shtml <http://www.admin.ox.ac.uk/examregs/03-00_REGULATIONS_ON_THE_NUMBER_AND_LENGTH_OF_TERMS.shtml> This document describes the start and end dates of Oxford Terms. In addition to this, the dates of Full Term, required to calculate the week number of the term, are prescribed by Council, and published periodically in the University Gazette. Full term comprises weeks 1-8 inclusive, but sometimes, dates outside of full term are presented in the Oxford academic date format. This module will optionally provide such dates. Data for these prescribed dates may be supplied in the file /etc/oxford-calendar.yaml; if this file does not exist, built-in data will be used. The built-in data is periodically updated from the semi-authoritative source at <http://www.ox.ac.uk/about_the_university/university_year/dates_of_term.html>. or the authoritative source, the Gazette, available online from <http://www.ox.ac.uk/gazette/>. <http://www.ox.ac.uk/about_the_university/university_year/index.html> describes the academic year at Oxford. DATE FORMAT
An Oxford academic date has the following format: <day of week>, <week number>[st,nd,rd,th] week, <term name> <year> where term name is one of o Michaelmas (autumn) o Hilary (spring) o Trinity (summer) Example: Friday, 8th Week, Michaelmas 2007 FUNCTIONS
ToOx($day, $month, $year, [\%options]) Given a day, month and year in standard human format (that is, month is 1-12, not 0-11, and year is four digits) will return a string of the form Day, xth week, Term year or an array (Day, week of term, Term, year) depending on how it is called. The exact behaviour is modified by the 'mode' option described below. If the requested date is not in full term or extended term (see below), undef will be returned. If the requested date is not covered by the database, ToOx will die with an "out of range" error message. Therefore it is recommended to eval ToOx with appropriate error handling. %options can contain additional named parameter options: mode Several modes are available: full_term Term dates will only be returned if the date requested is part of a full term (as defined by the web page above). ext_term Term dates will only be returned if the date requested is part of an extended term, or statutory term. nearest Will return term dates based on the nearest term, even if the date requested is not part of an extended term (i.e. will include fictional week numbers). This is currently the default behaviour, for backwards compatibility with previous releases; this may be changed in future. confirmed If true, ignores dates marked as provisional in the database. ThisTerm($year, $month, $day) Given a year, month, term in standard human format (that is, month is 1-12, not 0-11, and year is four digits) will returns the current term or undef if in vacation or unknown. The term is given as an array in the form (year, term). NextTerm($year, $month, $day) Given a day, month and year in standard human format (that is, month is 1-12, not 0-11, and year is four digits) will return the next term (whether or not the date given is in term time). The term is given as an array in the form (year, term). StatutoryTermDates($year) Returns a hash reference keyed on terms for a given year, the value of each being a hash reference containing start and end dates for that term. The dates are stored as array references containing numeric year, month, day values. Note: these are the statutory term dates, not full term dates. Parse($string) Takes a free-form description of an Oxford calendar date, and attempts to divine the expected meaning. If the name of a term is not found, the current term will be assumed. If the description is unparsable, undef is returned. Otherwise, an array will be returned of the form "($year,$term,$week,$day)". This function is experimental. FromOx($year, $term, $week, $day) Converts an Oxford date into a Gregorian date, returning a string of the form "DD/MM/YYYY" or undef. The arguments are of the same format as returned by ToOx in array context; that is, a four-digit year, the name of the term, the week number, and the name of the day of week (e.g. 'Sunday'). If the requested date is not covered by the database, FromOx will die with an "out of range" error message. Therefore it is recommended to eval ToOx with appropriate error handling. BUGS
Bugs may be browsed and submitted at http://rt.cpan.org/Public/Dist/Display.html?Name=Oxford-Calendar <http://rt.cpan.org/Public/Dist/Display.html?Name=Oxford-Calendar> A copy of the maintainer's git repository may be found at https://github.com/jmdh/Oxford-Calendar <https://github.com/jmdh/Oxford-Calendar> AUTHOR
Simon Cozens is the original author of this module. Eugene van der Pijll, "pijll@cpan.org" took over maintenance from Simon for a time. Dominic Hargreaves currently maintains this module for the Computing Services, University of Oxford. perl v5.14.2 2012-06-26 Oxford::Calendar(3pm)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy