Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to Loop through Quarter dates Post 303002394 by durden_tyler on Wednesday 23rd of August 2017 11:52:00 AM
Old 08-23-2017
Quote:
Originally Posted by krux_rap
...
...
Example

If I'm running on Sept 5th it has to generate one file(Becuase it falls under first Quarter), dates should be between 2017-07-01 and 2017-08-31 to Postgres SQL as Input.
  • July - Sept (1 file)
  • Oct - Dec (2 files which should generate above file too)
  • Jan - Mar (3 files)
  • April - Jun (4 files)

Another Example
If I ran the script on Nov 5th, then it has to get me 2 sets of files
  • One from July 1st to Sept 30th
  • 2nd file from Oct 1st to Oct 31st
...
...
What should be in the files if the end of previous month is also the end of previous quarter?

For example, if the process is run on 4-Oct-2017, then:
1) "File 1" has dates of Quarter 1 i.e. 01-Jul-2017 to 30-Sep-2017
2) What dates does "File 2" have?

A few similar cases are below:

Process Date: 05-Jan-2018
File 1 : Dates of Quarter 1 i.e. 01-Jul-2017 to 30-Sep-2017
File 2 : Dates of Quarter 2 i.e. 01-Oct-2017 to 31-Dec-2017
File 3 : What dates does this have?

Process Date: 05-Apr-2018
File 1 : Dates of Quarter 1 i.e. 01-Jul-2017 to 30-Sep-2017
File 2 : Dates of Quarter 2 i.e. 01-Oct-2017 to 31-Dec-2017
File 3 : Dates of Quarter 3 i.e. 01-Jan-2018 to 31-Mar-2018
File 4 : What dates does this have?

Also, what dates should be in the file(s) if the process is run in July of any year?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare the dates in shell script

Hi How to compare created or modified date of two files help needed thanks Vajiramani :) (9 Replies)
Discussion started by: vaji
9 Replies

2. Shell Programming and Scripting

Generate quarter dates with begin date and end date

Hi All, I am trying to generate quarter dates with user giving input as begin date and end date. Example: Input by user: begin_date = "2009-01-01" end_date = 2010-04-30" required output: 2009-01-01 2009-03-31 09Q01 2009-04-01 2009-06-30 09Q02 . . till 2010-01-01 2010-03-31 10Q01 ... (9 Replies)
Discussion started by: sol_nov
9 Replies

3. Shell Programming and Scripting

Difference of 2 dates in shell script

Hi., After retrieving values from DB I have two datestamps in format: 12/01/2010:05:40:00 AM and 12/01/2010:06:00:00 PM. general time format: MM/DD/YYYY:HH:MM:SS AM or PM Any quick solution to get the difference of two in the format : 1 day(s) 12:20:00 Thanks., (6 Replies)
Discussion started by: IND123
6 Replies

4. UNIX for Dummies Questions & Answers

Find Quarter Start and End Dates

Dear Members, Depending on the current date i should find out the start and end dates of the quarter. ex: Today date is 14-Nov-2011 then Quarter start date should be Oct 1 2011 and Quarter End date should be Dec 31 2011. How can i do this? Thanks Sandeep (1 Reply)
Discussion started by: sandeep_1105
1 Replies

5. Shell Programming and Scripting

append dates going forward from today to certain line in shell script

Hi there, I have a requirement to append dates going forward to a certain line in a file. I'm not sure of how to go about this. Any help will be greatly appreciated. Thanks Slyesco:wall: (2 Replies)
Discussion started by: Slyesco
2 Replies

6. Shell Programming and Scripting

Shell script to calculate difference between 2 dates

shell script to calculate difference between 2 dates (3 Replies)
Discussion started by: gredpurushottam
3 Replies

7. 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

8. Shell Programming and Scripting

Shell script to work on dates

Hi Sir/Madam I have a file data.txt like below file_name date_of_creation x 2/10/2012 y 8/11/2010 z 11/3/2013 a 2/10/2013 b 3/10/2013 c ... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

9. Shell Programming and Scripting

Comparing dates in shell script

Hi All, I have a date variable say dt="2014-01-06 07:18:38" Now i need to use this variable to search a log and get the entries which occured after that time. (1 Reply)
Discussion started by: Girish19
1 Replies

10. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies
PPPOE-SETUP(8)						      System Manager's Manual						    PPPOE-SETUP(8)

NAME
pppoe-setup - Shell script to configure Roaring Penguin PPPoE client SYNOPSIS
pppoe-setup DESCRIPTION
pppoe-setup is a shell script which prompts you for various pieces of information and sets up an /etc/sysconfig/network-scripts/ifcfg-ppp0 configuration script for the pppoe-start, pppoe-stop and +pppoe-connect scripts. AUTHOR
pppoe-setup was written by David F. Skoll <dfs@roaringpenguin.com>. The pppoe home page is http://www.roaringpenguin.com/pppoe/. SEE ALSO
pppoe(8), pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8), pppoe- server(8) 4th Berkeley Distribution 21 February 2000 PPPOE-SETUP(8)
All times are GMT -4. The time now is 08:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy