Find Quarter Start and End Dates


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find Quarter Start and End Dates
# 1  
Old 11-14-2011
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
# 2  
Old 11-15-2011
A shellish answer:
Code:
#! /bin/bash

l=( 0 J F 31 A M 30 J A 30 O N 31 )

m=$(date +%m)
(( s = ( $m - 1 ) / 3 * 3 + 1 ))
(( e = s + 2 ))

y=$(date +%Y)
echo ${m}/${y}: 1-${s}-${y} to ${l[${e}]}-$e-${y}

Running this day (15-11-2011) results in:
Code:
11/2011: 1-10-2011 to 31-12-2011

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

Shell Script to Loop through Quarter dates

Hi, 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... (12 Replies)
Discussion started by: krux_rap
12 Replies

4. Shell Programming and Scripting

Shell file if condition setting start and end dates

I have shell file that has the following logic, i am new to shell programming. What does process month $1 do? I am assuming that the below dates go back three months from sysdate month. is it right : curr_month=`date +%Y%m` Beg_o_time=`date -d "2012/03/01" +%Y%m` Process_months=$1... (1 Reply)
Discussion started by: cplusplus1
1 Replies

5. Shell Programming and Scripting

Find between lines start and end: awk with bash variables

I have a file as follows: 0 1056 85540 414329 774485 1208487 1657519 2102753 2561259 3037737 3458144 3993019 4417959 4809964 5261890 5798778 6254146 I want to find all lines between a specified start and end tag. (6 Replies)
Discussion started by: jamie_123
6 Replies

6. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

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

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

9. Shell Programming and Scripting

read a string from its end to its start and stop when you find a specific character

How can I do this? Actually I have a file which contains a path e.g. /home/john/Music/hello.mp3 and I want to take only the filename (hello.mp3) So, I need to read the file from its end to its start till the character "/" Is this possible? Thanks, I am sure you'll not disappoint me here! Oh,... (9 Replies)
Discussion started by: hakermania
9 Replies

10. 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
Login or Register to Ask a Question