Trying to automate a Postgres query using Shell script
Every month 1st week has to run a Monthly Queries to generate delimited files.
July 1st start of fiscal yr which has 4 Quarters until next June 30th
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
Code:
quarter_start_date=$(date +"%m %Y" | awk '{printf("%d-%02d-01\n", $2, int(($1 - 1) / 3) * 3 + 1)}')
echo $quarter_start_date
quarter_end_date=$(date '+%Y-%m-%d' -d "-$(date +%d) days")
echo $quarter_end_date
fiscal_year=$(date -d "+1 Year" "+%Y")
echo $fiscal_year
mon=$(date +'%m')
if [ $mon -ge 7 -a $mon -le 9 ]; then
qtr=1
elif [ $mon -ge 10 -a $mon -le 12 ]; then
qtr=2
elif [ $mon -ge 1 -a $mon -le 3 ]; then
qtr=3
elif [ $mon -ge 4 -a $mon -le 6 ]; then
qtr=4
fi
echo $qtr
Last edited by rbatte1; 08-22-2017 at 06:52 AM..
Reason: Added bullet lists
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT BSD
prof
PROF(1) General Commands Manual PROF(1)NAME
prof - display profile data
SYNOPSIS
prof [ -a ] [ -l ] [ -n ] [ -z ] [ -s ] [ -v [ -low [ -high ] ] ] [ a.out [ mon.out ... ] ]
DESCRIPTION
Prof interprets the file produced by the monitor subroutine. Under default modes, the symbol table in the named object file (a.out
default) is read and correlated with the profile file (mon.out default). For each external symbol, the percentage of time spent executing
between that symbol and the next is printed (in decreasing order), together with the number of times that routine was called and the number
of milliseconds per call. If more than one profile file is specified, the output represents the sum of the profiles.
In order for the number of calls to a routine to be tallied, the -p option of cc, f77 or pc must have been given when the file containing
the routine was compiled. This option also arranges for the profile file to be produced automatically.
Options are:
-a all symbols are reported rather than just external symbols.
-l the output is sorted by symbol value.
-n the output is sorted by number of calls
-s a summary profile file is produced in mon.sum. This is really only useful when more than one profile file is specified.
-v all printing is suppressed and a graphic version of the profile is produced on the standard output for display by the plot(1) fil-
ters. When plotting, the numbers low and high, by default 0 and 100, may be given to cause a selected percentage of the profile to
be plotted with accordingly higher resolution.
-z routines which have zero usage (as indicated by call counts and accumulated time) are nevertheless printed in the output.
FILES
mon.out for profile
a.out for namelist
mon.sum for summary profile
SEE ALSO monitor(3), profil(2), cc(1), plot(1G)BUGS
Beware of quantization errors.
Is confused by f77 which puts the entry points at the bottom of subroutines and functions.
4th Berkeley Distribution April 29, 1985 PROF(1)