# date problem

**URL:** <https://community.unix.com/t/date-problem/284565>\
**Category:** Shell Programming and Scripting\
**Created:** [March 15, 2011, 2:45am UTC](https://community.unix.com/t/date-problem/284565 "2011-03-15T02:45:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aishsimplesweet](https://community.unix.com/letter_avatar/aishsimplesweet/32/6_449c533f586939b6e5f246632a46421f.png) [@aishsimplesweet](https://community.unix.com/u/aishsimplesweet)\
**Post date:** [March 15, 2011, 2:45am UTC](https://community.unix.com/t/date-problem/284565/1 "2011-03-15T02:45:26Z")

</div>

hi everyone

i have another date problem

i need to find out the last week number and in that last week i need to find out at what day monday comes.

please help

---

<div class="post-metadata">

**Author:** ![danmero](https://community.unix.com/letter_avatar/danmero/32/6_449c533f586939b6e5f246632a46421f.png) [@danmero](https://community.unix.com/u/danmero)\
**Post date:** [March 15, 2011, 5:42am UTC](https://community.unix.com/t/date-problem/284565/2 "2011-03-15T05:42:45Z")

</div>

The solution depend on your operating system.

```nohighlight
# uname -v
FreeBSD 7.3-RELEASE-p3 #0: Tue Nov 2 22:42:55 CET 2010

# date -v -1w -v $((($(date +%u) - 1)* -1))d
Mon Mar 7 05:38:32 EST 2011

# date -v -1w -v $((($(date +%u) - 1)* -1))d +%d
07

```

---

<div class="post-metadata">

**Author:** ![aishsimplesweet](https://community.unix.com/letter_avatar/aishsimplesweet/32/6_449c533f586939b6e5f246632a46421f.png) [@aishsimplesweet](https://community.unix.com/u/aishsimplesweet)\
**Post date:** [March 15, 2011, 5:58am UTC](https://community.unix.com/t/date-problem/284565/3 "2011-03-15T05:58:19Z")

</div>

hi

above command is giving me error as

My operating system is sun solaris can we don this command on this

```nohighlight
 
-bash-3.00$ date -v -1w -v $((($(date +%u) - 1)* -1))d
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- w
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- d
usage: date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
-bash-3.00$ date -v -1w -v $((($(date +%u) - 1)* -1))d +%d
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- w
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- d
usage: date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
-bash-3.00$

 

```

---

<div class="post-metadata">

**Author:** ![danmero](https://community.unix.com/letter_avatar/danmero/32/6_449c533f586939b6e5f246632a46421f.png) [@danmero](https://community.unix.com/u/danmero)\
**Post date:** [March 15, 2011, 6:09am UTC](https://community.unix.com/t/date-problem/284565/4 "2011-03-15T06:09:42Z")

</div>

My solution work for FreeBSD date only. Sorry but you didn't state you OS from head-start.

---

<div class="post-metadata">

**Author:** ![aishsimplesweet](https://community.unix.com/letter_avatar/aishsimplesweet/32/6_449c533f586939b6e5f246632a46421f.png) [@aishsimplesweet](https://community.unix.com/u/aishsimplesweet)\
**Post date:** [March 15, 2011, 6:16am UTC](https://community.unix.com/t/date-problem/284565/5 "2011-03-15T06:16:32Z")

</div>

okkk can u tell me solution for my operating system

it's imp to me

or

can you tell me the solution if i want to find the last monday of the current date in unix

---

<div class="post-metadata">

**Author:** ![danmero](https://community.unix.com/letter_avatar/danmero/32/6_449c533f586939b6e5f246632a46421f.png) [@danmero](https://community.unix.com/u/danmero)\
**Post date:** [March 15, 2011, 6:58am UTC](https://community.unix.com/t/date-problem/284565/6 "2011-03-15T06:58:09Z")

</div>

Take a look at second answer on this thread: [date -d compatibility on Solaris - The UNIX and Linux Forums](http://www.unix.com/shell-programming-scripting/106240-date-d-compatibility-solaris.html)
