Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Based on Today's date I want Monday's Date 1

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
US
I want the date of the Monday of the week that I'm currently in...Possible??

Thanks,

DLC
 
I'll make the assumption that you always want the previous Monday:

If dayofWeek(currentdate) =1 then
currentdate - dayofWeek(currentdate) -5
else
currentdate - dayofWeek(currentdate) + 2

If not, this gets this weeks Monday (week starts Sunday):

If dayofWeek(currentdate) =1 then
currentdate+1
else
currentdate - dayofWeek(currentdate) + 2

-k
 
You really only need the second line of SV's formula if you want to find Monday of the current week.

currentdate - dayofWeek(currentdate) + 2

Subtracting the DayOfWeek from a date gives you the previous Saturday and adding 2 gives you Monday

Mike
 
Ahhh, good point, Mike, I hurriedly tossed that in at the last moment thinking that they probably meant the previous Monday and it wasn't really needed anyway.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top