?
Solved

Showing a date range

Posted on 2013-11-25
3
Medium Priority
?
168 Views
Last Modified: 2013-11-25
I would like to be able to display the dates from Monday to Friday of a particular week on a report using the system date (which will be a date that falls during that particular week, between Mon to Friday). For example, if the system date is 11/27/2013, it will show: 11/25/13 - 11/29/13. If the date is 11/26/13, it will still show: 11/25/13 - 11/29/13. If the date is 12/5, it will show: 12/2-12/6.

Is there anyway I could accomplish this?
0
Comment
Question by:geeta_m9
[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
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 39675178
<Is there anyway I could accomplish this? >

yes, but you need to create a user define function in vba

sample

Function GetWeekDate(d As Date)  
Dim monDate As Date
monDate = d + 1 - Weekday(d, 2)
GetWeekDate = monDate & "-" & DateAdd("d", 4, monDate)
End Function
0
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 1000 total points
ID: 39675623
to get the date of the Monday of the current week (Mon-Fri), use:

?dateadd("d", weekday(date(), vbMonday) -1, date())

To get the Friday of the same week, use:

?dateadd("d", 5-weekday(date(), vbMonday), date())
0
 

Author Closing Comment

by:geeta_m9
ID: 39675840
Both the solutions work well, thanks.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

719 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