473,659 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I find the week ending date?

31 New Member
Hi All,

Edit:

I currently have table where I need to find the Week Ending date for a rolling 15 weeks, where each week is a separate column. It goes from Sched01 - Sched15.

The Sched01 column is always the current Week Ending Date (Saturday). However, if a month ends on any other day but Saturday then I need the month end date to be the Week Ending Date.

For example as of 7/22/2011:
Sched01 - Week Ending Date is currently 7/23/2011
Sched02 - Week Ending Date is currently 7/30/2011
Sched03 - Week Ending Date is currently 7/31/2011
Sched04 - Week Ending Date is currently 8/06/2011

For example as of 7/25/2011:
Sched01 - Week Ending Date is currently 7/30/2011
Sched02 - Week Ending Date is currently 7/31/2011
Sched03 - Week Ending Date is currently 8/06/2011
Sched04 - Week Ending Date is currently 8/13/2011

Any help is appreciated.
Jul 21 '11 #1
9 5310
Rabbit
12,516 Recognized Expert Moderator MVP
If you subtract the weekday number of the date from 7, and then add that many days to the date, that will give you the week ending date.

Then you check if that date is in the next month, if it is, you use the end of the month.
Jul 21 '11 #2
NeoPa
32,568 Recognized Expert Moderator MVP
What's in your table?

Always 15 records? A history including 15 for the upcoming weeks?

When are you requiring to show/use these values?

There are so many possible approaches to this, that without more info it's unprofitable trying to answer.
Jul 23 '11 #3
BarbQb
31 New Member
NeoPa-

The table contains product production by week.

One record is product X and the Production Amount in the following 42 weeks (columns Sched01-Sched42), but I am only interested in the first 15 weeks (columns Sched01-Sched15).

There is no history in the table. Sched01 is always the current Week Ending Date.

I would like to show everything that is being produced in each of the 15 weeks, but the problem is finding the dates for each week. The users will be checking this schedule 2-3 times per week.

Eventually I would like to join it with another table that shows the product that is coming in each week. I have already configured the dates for that table, but they are not set up the same way.

Please let me know if you need any more information.
Jul 23 '11 #4
NeoPa
32,568 Recognized Expert Moderator MVP
So I guess you have a form or report, or other similar object, where you wish to update the display for the column titles so that instead of showing just Sched01, Sched02, etc, it shows the W/E dates for each column. Is that right?

If so, what type of object are we dealing with? A form? A report?
Jul 23 '11 #5
BarbQb
31 New Member
Sorry about that.

I would like for the column titles to be the W/E date and not Sched01, 02,... I am just working with a query right now. Eventually I will put it into a report.
Jul 25 '11 #6
NeoPa
32,568 Recognized Expert Moderator MVP
Right. I think we need to get something clear here at this point :

Column titles in queries cannot be determined from within the query. Column titles can be assigned to a query, but not from within the query itself. The columns must be available and in the query (design) itself and are not dependent on, or ralative to, the data at any particular time of processing the query. Furthermore, even if it were possible to determine the column headings in this way for the query, it would make it impossible/insanely difficult to use that query for a report. It is possible to create the query (SQL) with your desired columns titles in VBA code on the fly. Because this would be unproductive though, as far as using in a report, I will ignore this for now.

All that said, you can only really benefit by determining the titles within the report itself (This would also be true for a Form if that were your requirement).

Before continuing I'd like you to confirm that you understand and accept what I've just said, and my proceeding along these lines will make sense. It does mean, of course, that your development of the query can go ahead without further delay as there is really no need at this point to worry about the titles (The controls in the eventual report will need to be bound to fields from the query with names that are known in advance. IE. The known ones of Sched01, Sched02, etc.).
Jul 25 '11 #7
BarbQb
31 New Member
Thanks NeoPa. I think I jumped ahead of myself when I said I wanted to change the column titles in the Query. I definitely had an idea in my head that will not be plausible.

But, I do understand and agree that it will be beneficial to figure out the Week Ending Dates within the report.
Jul 26 '11 #8
NeoPa
32,568 Recognized Expert Moderator MVP
I can't test this without your database but it should work hopefully (It compiles ok at least) :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub Report_Open(Cancel As Integer)
  5.     Dim intSched As Integer, intMonth As Integer
  6.     Dim datNext As Date, datSat As Date
  7.  
  8.     datNext = Date
  9.     datSat = DateAdd("d", 7 - Weekday(datNext), datNext)
  10.     For intSched = 1 To 15
  11.         If Month(DateAdd("d", 1, datNext)) = Month(datSat) Then
  12.             datNext = datSat
  13.             datSat = DateAdd("d", 7, datSat)
  14.         Else
  15.             datNext = DateAdd("d", -1, CDate(Format(datSat, "m/yyyy")))
  16.         End If
  17.         With Me.Controls("txtSched" & Format(intSched, "00"))
  18.             .Caption = Format(datNext, "ddd d mmm yyyy")
  19.         End With
  20.     Next intSched
  21. End Sub
You can choose how you want the column titled by changing line #18.
Jul 27 '11 #9
BarbQb
31 New Member
Thank you very much, NeoPa. I will let you know how it works.
Aug 2 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5867
by: David Olsen | last post by:
Would any of you kind souls now how to put into an unbound text box the week commencing date for the current week which you are in, so that the report heading would say something like for example, orders registered to date this "week commencing"--then the text box.Using Monday as the first day of the week. Many Thanks David
3
5930
by: Matt | last post by:
Given a date, how to find the beginning date and ending date of that week please advise!
4
2138
by: csgraham74 | last post by:
Hi Guys, I was wondering if anyone could help me find a function to get a week ending function?? i.e. week ending on sunday Therefore if a i was to input todays date in my function it would output the sunday date of the same week. If anyone has a such a function or can point me in the right direction it would be most
7
9043
by: derekdeben | last post by:
Hi, I have created a report that totals the number of days it took a product to ship by percentage by a date range for a specific location. My data comes from a query with the following headers: I used a count iff to calculate the following headers in the report. This is a percent of the total number of packages.
2
1748
by: nex85 | last post by:
hi! HOUR FROM TIME i) does anyone know how to determine which hour a time value lies in? the arrival time is in hh:mm:ss format. for e.g.: for an arrival time of 17:00:26, the correct conversion should be: 17:00. DAY OF THE WEEK FROM DATE IN VBA ii) if a cell's value is a date, in the form: 14/08/2006, how would you detect which day of the week is it? like monday, tuesday, wednesday, etc. APPEND DATE AND DATE STRING iii) is it...
1
5365
by: GoDogGo | last post by:
I need code to find next Tuesdays date. I have started with this: TuesdaysDate = DateAdd("d", vbTuesday - Weekday(Date), Date) However if today is Wednesday it returns yesterdays date. I need to find next Tuesday's date. Can anyone help?
3
2773
Inbaraj
by: Inbaraj | last post by:
Hi... I have a Table in that i have inserted the DATE as VARCHAR now in that i Want to get the Max Date. I am new to MySQL Plz help me how to find the max date. with regard Inbaraj.D
2
1159
by: juster21 | last post by:
I need to be able to have my application select the current week-ending date from a listbox. I have seen some things on the net but nothing that really helps. If anyone can provide help, that would be awesome. p.s. - the dates are prefilled in the listbox in mm/dd/yyyy format.
0
2065
by: jmarcrum | last post by:
Hi all, I have an excel spreadsheet that in column A, has a formula under the first row in A2 that automatically calculates the Week-ending date when someone starts typing something in cells B2, C2, D2, E2, or F2...and so on, down through row A500. Here's my formula... =IF(OR(B2<>"",C2<>"",D2<>"",E2<>"",F2<>""),NOW()+7-WEEKDAY(NOW(),1),"") However, here's my problem...
2
10269
akashazad
by: akashazad | last post by:
Dear Friends I would Like to know if there is any way we can find the Current Date format of the Server. I mean is there any Query or function by which we can find out the the Date format on SQL Server is either "MM/DD/YYYY" or "DD/MM/YYYY" or Any thing Else.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.