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.
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.
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.
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.
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?
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.
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.).
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.
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) : - Option Compare Database
-
Option Explicit
-
-
Private Sub Report_Open(Cancel As Integer)
-
Dim intSched As Integer, intMonth As Integer
-
Dim datNext As Date, datSat As Date
-
-
datNext = Date
-
datSat = DateAdd("d", 7 - Weekday(datNext), datNext)
-
For intSched = 1 To 15
-
If Month(DateAdd("d", 1, datNext)) = Month(datSat) Then
-
datNext = datSat
-
datSat = DateAdd("d", 7, datSat)
-
Else
-
datNext = DateAdd("d", -1, CDate(Format(datSat, "m/yyyy")))
-
End If
-
With Me.Controls("txtSched" & Format(intSched, "00"))
-
.Caption = Format(datNext, "ddd d mmm yyyy")
-
End With
-
Next intSched
-
End Sub
You can choose how you want the column titled by changing line #18.
Thank you very much, NeoPa. I will let you know how it works.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
by: Matt |
last post by:
Given a date, how to find the beginning date and ending date of that week
please advise!
|
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
|
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.
|
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...
| |
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?
|
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
|
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.
|
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...
|
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.
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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...
|
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...
| |