Get Quarter Date


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Get Quarter Date
# 1  
Old 12-22-2010
Get Quarter Date

Hi

I need to produce a report that the start date must be the first day of the current quarter. Therefore a repor that is run today the start date would be 01/10/2010 (ddmmyyyy).

Obvioulsy I could hard code this date in but what happens when the report is run in January the start of the current quarter would then be 01/01/2011 (ddmmyyyy).

Please can someone advise how I can use todays date to work out what quater date the start date should be.

Thanks

# 2  
Old 12-22-2010
This gives the first day of the current quarter:
Code:
date +"%m %Y" | awk '{printf("01-%02d-%d\n", int(($1 - 1) / 3) * 3 + 1, $2)}'

# 3  
Old 12-23-2010
Sorry to be a pain but coould you show me what I would need to amend to make the date in yyyy-mm-dd format. I've tried switiching the parameters around but I end up with some very weird results!

./pjg

Last edited by theref; 12-23-2010 at 10:59 AM..
# 4  
Old 12-23-2010
Code:
date +"%m %Y" | awk '{printf("%d-%02d-01\n", $2, int(($1 - 1) / 3) * 3 + 1)}'


Last edited by anurag.singh; 12-23-2010 at 11:25 AM..
# 5  
Old 12-23-2010
Thanks for the swift reply.

This is bringing back 10-01-2010 when I need it bring back:

2010-10-01

Could you please advise what would be required to get it in this format.

Thanks

./pjg
# 6  
Old 12-23-2010
My mistake, corrected in previous post. Now displayed format is: yyyy-mm-dd
This is just a rearrangement of format specifier in printf along with associated values.

Last edited by anurag.singh; 12-23-2010 at 11:38 AM..
# 7  
Old 12-23-2010
Top man, thanks.

./pjg
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

4. Shell Programming and Scripting

Get 1st date of month, week , quarter

Hi , I need to trigger few jobs based on the system date ( in case user is not passing any date to the script. In case passing then need to take the user date). Here is the requirement 1. Everyday call daily script 2. On 1st day of week call weekly script 3. On 1st day of month call... (4 Replies)
Discussion started by: Anupam_Halder
4 Replies

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

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

7. Shell Programming and Scripting

extract the relevant data files for a quarter

CTB_KT_OllyotLvos_20081204_164352_200811.txt CTB_KT_LN_utahfwd_20081204_164352_200811.txt CTB_KT_LN_utahfwd_Summ_20081204_164352_200811.txt CTB_KT_PML_astdt_prFr_20081204_210153_200811.txt CTB_KT_PML_astdt_prOt_20081204_210153_200811.txt CTB_KT_PML_astdt_Nopr_20081204_210153_200811.txt... (7 Replies)
Discussion started by: w020637
7 Replies

8. UNIX for Dummies Questions & Answers

code to identify the New Quarter

I am a sql programmer, I don't know much about UNIX. I want to modify the existing unix script ----------------------------------------------------------------- ............ cd /home/location/file set timing on sqlplus user/$IDPW <<! prompt RUNNING NEW QUARTER PROCESSING. PLEASE WAIT.... (1 Reply)
Discussion started by: stefani
1 Replies

9. UNIX for Advanced & Expert Users

How can i calculate a Quarter of a Month

I im just a beginner here. I wanted to know how to calculate the Quarter of a Month, and i want to assign Number like if the month falls on 1st quarter then i have to assign to 1 then going on till the last Quarter!! Any help will be much use to me.. ~Renne (2 Replies)
Discussion started by: pidu_rak
2 Replies
Login or Register to Ask a Question