Solved

Getting previous week's date range

Posted on 2002-03-15
11
225 Views
Last Modified: 2010-05-02
How would I write a function that returns the previous week's date range?  For instance, if the run date is Monday 3/18/2002, it'll return "3/10/2002 - 3/16/2002."
0
Comment
Question by:arichexp
  • 4
  • 4
  • 3
11 Comments
 
LVL 3

Expert Comment

by:Bahnass
ID: 6869565
TRY THIS
DEBUG.PRINT  (DATE - WEEKday(date)),(DATE - WEEKday(date)-7)
0
 

Accepted Solution

by:
bill02 earned 50 total points
ID: 6869571
label1.caption = DateAdd("d", -7, Now) - DateAdd("d", 7, Now)
0
 

Expert Comment

by:bill02
ID: 6869576
label1.caption = DateAdd("d", -7, Format(Now, "mm/dd/yyyy")) & " - " &  DateAdd("d", 7, Format(Now, "mm/dd/yyyy"))

sorry
0
 

Author Comment

by:arichexp
ID: 6869587
But what if the run date is any day of the week, not just Monday?
0
 

Expert Comment

by:bill02
ID: 6869914
this should do what you need replace now with your dates and format them ass you  wish



Label1.Caption = DateAdd("d", (-(Weekday(Now) - 1)), Now) & " - " & DateAdd("d", (7 - (Weekday(Now))), Now)
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:bill02
ID: 6869916
im sooooooo sorry i did not mean ass i as sorry
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6870615
Did U C MY POST


DEBUG.PRINT  (DATE - WEEKday(date)),(DATE - WEEKday(date)-7)

1     Date     returns current date
2     WeekDay returns a number of day in week  

So please try it

pls give feedback  ( if U need to reject Bill answer U can do it simply )

0
 

Author Comment

by:arichexp
ID: 6872698
Thanks, although I modified it slightly for a datetime field, i.e.

date_beg = Date - Weekday(Date) - 6 & " 00:00:00"
date_end = Date - Weekday(Date) & " 23:59:59"
0
 

Author Comment

by:arichexp
ID: 6872705
Thanks Bahnass!
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6873004
arichexp

Where is my Points !!!!!

WeekDay from beginning !!!!!
0
 

Author Comment

by:arichexp
ID: 6873022
For some reason, the points went to bill02, even though I accepted your comment as the answer.  Is there a bug of somekind?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 49
Restricting text box entry from \/:?<>"| 9 62
Run code from text file in vb 1 33
Visual Studio 2005 text editor 10 20
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

19 Experts available now in Live!

Get 1:1 Help Now