ONE week back based today

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: ONE week back based today

1. Registered User
Join Date
Mar 2005
Posts
37

## ONE week back based today

Based the today date wath is the date of moonday and freeday of first one back week?

for example:

today is 27/03/2012

monnday 19/03/2012
fryday 23/03/2013

....

today is 12/03/2012

monnday 05/03/2012
fryday 09/03/2013

how to calculate this steep of dates?

2. Try
Code:
```Private Sub Command1_Click()
End Sub```

3. Registered User
Join Date
Mar 2005
Posts
37
[QUOTE=Hack;532433]Try
Code:
```Private Sub Command1_Click()
End Sub```
[/QUOTE

But you code return a TUESDAY and not a MONDAY (day init of one back week)

in other case i ned to have also the FRIDAY date of one back week... how to?
Last edited by luca90; 03-27-2012 at 03:24 PM.

4. Try these functions. Both will find the last Friday and last Monday based on the date passed to it
Code:
```Option Explicit

Private Function FindLastMonday(ByVal pintDayOfWeek As VbDayOfWeek, ByVal pdteDateToCheckAgainst As Date) As Date
Do
Loop Until Weekday(pdteDateToCheckAgainst) = pintDayOfWeek
FindLastMonday = pdteDateToCheckAgainst

End Function

Private Function FindLastFriday(ByVal pintDayOfWeek As VbDayOfWeek, ByVal pdteDateToCheckAgainst As Date) As Date
Do
Loop Until Weekday(pdteDateToCheckAgainst) = pintDayOfWeek
FindLastFriday = pdteDateToCheckAgainst

End Function

Private Sub Command1_Click()
Text1.Text = FindLastFriday(vbFriday, Format(Now, "mm/dd/yyyy"))
Text2.Text = FindLastMonday(vbMonday, Format(Now, "mm/dd/yyyy"))
End Sub```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise