List Info

Thread: Re: date/getdate.y: Relative days




Re: date/getdate.y: Relative days
country flaguser name
United Kingdom
2007-03-04 16:57:50
Akim Demaille wrote:
> I'm trying to find a means, given a week number, to
find the date of
> the Monday and Friday.  I was wondering if I could use
GNU date to do
> that straightforwardly instead of having to program
this.
> 

Akim,

%u (numerical-day-of-week) is useful here

This should work


DATE="10 august 2007"  # a random date
OFFSET=$(( $(date --date="$" +%u ) - 1))
date --date="$DATE $OFFSET days ago"

HTH,
Colin S. Miller



BTW,
The first week (before the week's start day),
can be week 0 in some systems.

_______________________________________________
help-gnu-utils mailing list
help-gnu-utilsgnu.org

http://lists.gnu.org/mailman/listinfo/help-gnu-utils

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )