Enter number of days and get calender


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Enter number of days and get calender
# 1  
Old 03-15-2013
Code Enter number of days and get calender

Friends need assistance in getting a script either on shell or perl. Below is the situation

Taking Today's calender into consideration with Month,Day,Year current .Using that i would like give number of days to get its month,day,year for future or past calender depending on the + or - days specified.example below

Code:
bash-2.05$ date|awk '{print $1" "$2" "$3" "$6}'
Fri Mar 15 2013

Enter No of day :  45 days
Mon Apr 29 2013

Thank you in advance.
# 2  
Old 03-15-2013
Code:
$ date -d "45day" +"%a %b %d %Y"
Mon Apr 29 2013
$ date --version
date (GNU coreutils) 8.13

# 3  
Old 03-15-2013
Since it is Solaris -d option does'nt support.

Code:
bash-2.05$ date -d "45day" +"%a %b %d %Y"
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]

# 4  
Old 03-15-2013
You can install GNU date somewhere, if it is not hiding in a dir somewhere or on the Solaris CD. I recall seeing a lot of GNU on Solaris installs, and I think it came from Sun. Or, you can compile my universal time 2 time tm2tm utility: https://www.unix.com/shell-programmin...bsd-linux.html

These guys got it abusing $TZ: http://www.linuxmisc.com/12-unix-she...0675c78895.htm
# 5  
Old 03-15-2013
Have a look at Perderabo's date calculator
Code:
$ datecalc -a 2013 03 15 + 45
2013 4 29

# 6  
Old 03-18-2013
Yoda. Is there a way of getting a SHELL script of taking user input of days and get result in . Date::Calc perl module not installed on the server and i dont have rights to install it.

Code:
MM:DD:YY

.
# 7  
Old 03-20-2013
C and JAVA date stuff is all in the core classes. Who would install PERL missing Date ! Put in a defect report? Maybe there are others, apparently many: The Many Dates and Times of Perl - Perl.com
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get number of days between 2 dates

Gents. Please can u help. I would like to calculate the days between two dates. Example file1 ( previous date) file1 - Input file 9/29/2010 10195 9/29/2010 1057 2/2/2016 10 2/2/2016 10169 2/2/2016 1057 2/3/2016 10005 2/3/2016 10014 In file2 I add the actual date using this code.... (9 Replies)
Discussion started by: jiam912
9 Replies

2. UNIX for Dummies Questions & Answers

Print enter line number

Hi, I have below text file wer,r5yut,dfy5y,dytry w45w,vbjjbh,xfsd,ctfyuk xdte56,rty6r,r645,976fd w34r,dtyer,d5tyty,fdyrt I want to get an O/P the enter rows for example if I enter 2, the first row should print output wer,r5yut,dfy5y,dytry w45w,vbjjbh,xfsd,ctfyuk (4 Replies)
Discussion started by: stew
4 Replies

3. Shell Programming and Scripting

Number of days in current month

I have a homework assignment: ---------------------------------------- "Display" the number of days in the current month. For example: September 1996 has 30 days ---------------------------------------- I am trying to just display the head of cal to start the sentence. eg. cal | head ... (1 Reply)
Discussion started by: eaafuddy
1 Replies

4. Shell Programming and Scripting

Delete a directory after X number of days

Hi How do I remove a directory which are some days old . For Ex : $ cd /WMID/data/temp/TxTest/Dev/txStore $ ls -ltr total 0 drwxr-xr-x 3 wmethods wmapp 80 Jul 21 03:36 0AE445C4 drwxr-xr-x 3 wmethods wmapp 80 Jul 21 04:00 0AE44664 drwxr-xr-x 3 wmethods... (6 Replies)
Discussion started by: leo76
6 Replies

5. Shell Programming and Scripting

Number of days in month from certain parameters

Hi, I have an issue in date processing, the issue is I have a month as an int ( 1 - 12 ), the weekday as int ( 0 - 6 , 0 = Sunday), and the week day in month as int ( 0 - 5, 5 = last ex: first sunday, last monday, third tuesday ... ), now from those three parameters is there a possible way to... (5 Replies)
Discussion started by: modn3
5 Replies

6. Shell Programming and Scripting

Number of days in the previous month

Hi all. I am scripting in a POSIX shell on HPUX. I am running a script that needs to determine the number of days in a month. I found this on the forum and it works great: X=`cal $(date +%m) $(date +%Y) | grep -v '' | wc -w` The issue is that I am running the script on the 7th day of... (11 Replies)
Discussion started by: lyoncc
11 Replies

7. Shell Programming and Scripting

Get number of days between given dates

Hi I need one single command to get number of days between two given dates.datecalc is not working. ex. fromdate:01.04.2010 todate :24.04.2010 i should get the out put as 23 Thanks in advance (4 Replies)
Discussion started by: suryanarayana
4 Replies

8. Shell Programming and Scripting

number of working days

Hi There, Can you help me writing an unix script which tells me number of working days between two dates. say d1 and d2. The answer should be Integer. is it possible in Unix. cheers, (1 Reply)
Discussion started by: rahulkav
1 Replies

9. UNIX for Advanced & Expert Users

Number of days between two distinct dates

Hi I'm looking for a .ksh script/function that will calculate ONLY the number of days between two distinct dates. Further convert the number of days to weeks and display. I need this to be part of another larger script that checks the password expiry on several servers and notifies the... (1 Reply)
Discussion started by: radheymohan
1 Replies

10. Shell Programming and Scripting

Calc number of days in a month

Looking for some help on capturing the number of days in a month to set as a loop counter. Any ideas, please let me know. (3 Replies)
Discussion started by: flounder
3 Replies
Login or Register to Ask a Question