Solved

date command

Posted on 2002-04-29
4
220 Views
Last Modified: 2010-04-20
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
Comment
Question by:arvind
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
newmang earned 50 total points
Comment Utility
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
 
LVL 5

Author Comment

by:arvind
Comment Utility
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
 
LVL 5

Author Comment

by:arvind
Comment Utility
Thnx newmang , Its working fine ....
0
 
LVL 5

Author Comment

by:arvind
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now