?
Solved

Getting previous week's date range

Posted on 2002-03-15
11
Medium Priority
?
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

800 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