[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

date command

I would like the print the week(date)  like week 17 startdate of week and enddate of week. sunday is the start day of week .So result like :

week 17 7 April 2002 to 14 April 2002

Any body can ??
0
arvind
Asked:
arvind
  • 3
1 Solution
 
newmangCommented:
What about something like this?

typeset -i dow
typeset -i num
dow=`date +%w`
num=6-$dow
week=`date +%U`
sunday=`date -d "today-$dow days" +"%e %B %Y"`
saturday=`date -d "today+$num days" +"%e %B %Y"`
echo +"Week $week $sunday to $saturday"


Cheers - Gavin
0
 
arvindAuthor Commented:
Here is the out put of ur script.
+Week 17 28 April 2002 to

So I would like the out put : Week 17, 7 April to 14 April 2002.

0
 
arvindAuthor Commented:
Thnx newmang , Its working fine ....
0
 
arvindAuthor Commented:
newmang one problem. PLs try to run this script on sunday or saturday. Its not giving the right output. Example I'd run this script sunday morning 7 AM _ I'd got week 18 5may to 6th may.

Could pls correct the problem
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now