I am trying to write a function that determines how many hours there are
until a certain date/time that depends on what today's date/time is.
Basically, how many hours from now until the next time that it is 8am on
Monday.
I've found the dateadd, hour, and weekday functions, but I can't seem to
get it straight in my head how to use them in this case. 6 2047
On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospa m.com>
wrote: I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is.
Basically, how many hours from now until the next time that it is 8am on Monday.
I've found the dateadd, hour, and weekday functions, but I can't seem to get it straight in my head how to use them in this case.
Use DateDiff. Try this in the immediate window.
?DateDiff("h",N ow(),#9/13/04 8:00 AM#)
88
So, as I write this there are 88 hours until next monday 8 AM.
- Jim
Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospa m.com> wrote:I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is.
Basically, how many hours from now until the next time that it is 8am on Monday.
Use DateDiff. Try this in the immediate window.
?DateDiff("h",N ow(),#9/13/04 8:00 AM#) 88
So, as I write this there are 88 hours until next monday 8 AM.
Thanks for your reply. Actually, I already got that much though.
The trick I am looking for is determining what value should be filled in
for #9/13/04# on the fly. It needs to calculate how many hours til the
next Monday at 8am depending on WHICH Monday that happens to be based on
the current day.
Hi,
Found a couple of datetime functions that might help. Try this. I tested
it in the Immediate Window.
Public Function DoMondayAtEight ()
Dim hours As Integer
Dim nextMonday As Integer
Dim result As Integer
hours = Weekday(Now()) - 1
hours = hours * 24 + Hour(Now())
Debug.Print hours
nextMonday = (vbMonday - 1) * 24
nextMonday = nextMonday + 8
Debug.Print nextMonday
If hours <= nextMonday Then
result = nextMonday - hours
Else
result = ((7 * 24) - hours) + nextMonday
End If
Debug.Print result
End Function
Linda
"HateSpam" <Ha******@nospa m.com> wrote in message
news:5M******** ********@fe1.co lumbus.rr.com.. . Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospa m.com> wrote:I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is.
Basically, how many hours from now until the next time that it is 8am on Monday.
Use DateDiff. Try this in the immediate window.
?DateDiff("h",N ow(),#9/13/04 8:00 AM#) 88
So, as I write this there are 88 hours until next monday 8 AM.
Thanks for your reply. Actually, I already got that much though.
The trick I am looking for is determining what value should be filled in for #9/13/04# on the fly. It needs to calculate how many hours til the next Monday at 8am depending on WHICH Monday that happens to be based on the current day.
Squirrel wrote: Found a couple of datetime functions that might help. Try this. I tested it in the Immediate Window.
[code snipped]
Perfect. You rock.
HateSpam <Ha******@nospa m.com> wrote in message news:<5M******* *********@fe1.c olumbus.rr.com> ... Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospa m.com> wrote:I am trying to write a function that determines how many hours there are until a certain date/time that depends on what today's date/time is.
Basically, how many hours from now until the next time that it is 8am on Monday.
Use DateDiff. Try this in the immediate window.
?DateDiff("h",N ow(),#9/13/04 8:00 AM#) 88
So, as I write this there are 88 hours until next monday 8 AM.
Thanks for your reply. Actually, I already got that much though.
The trick I am looking for is determining what value should be filled in for #9/13/04# on the fly. It needs to calculate how many hours til the next Monday at 8am depending on WHICH Monday that happens to be based on the current day.
I started on this. The "find the next monday" thing is easy. The
trick, I guess, is to check what the current date/time it is. Then if
it's Monday, you keep going. I'll post it later today.
You basically use a do loop and add a day to a temp date. And then
you check for meeting your criteria outside the loop and you're there.
HTH,
Pieter pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ****@posting.go ogle.com>... HateSpam <Ha******@nospa m.com> wrote in message news:<5M******* *********@fe1.c olumbus.rr.com> ... Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospa m.com> wrote: >I am trying to write a function that determines how many hours there are >until a certain date/time that depends on what today's date/time is. > >Basically, how many hours from now until the next time that it is 8am on >Monday.
Use DateDiff. Try this in the immediate window.
?DateDiff("h",N ow(),#9/13/04 8:00 AM#) 88
So, as I write this there are 88 hours until next monday 8 AM.
Thanks for your reply. Actually, I already got that much though.
The trick I am looking for is determining what value should be filled in for #9/13/04# on the fly. It needs to calculate how many hours til the next Monday at 8am depending on WHICH Monday that happens to be based on the current day.
I started on this. The "find the next monday" thing is easy. The trick, I guess, is to check what the current date/time it is. Then if it's Monday, you keep going. I'll post it later today. You basically use a do loop and add a day to a temp date. And then you check for meeting your criteria outside the loop and you're there.
HTH, Pieter
Hello -
Think this might return what you're after -
Function FutureDate(Optional pTarget As Integer = vbMonday) As Integer
-
Dim dteNow As Date
-
Dim dteNew As Date
-
Dim intDay As Integer
-
-
dteNow = Now()
-
intDay = pTarget
-
dteNew = Int(dteNow - WeekDay(dteNow) + intDay + _
-
IIf(WeekDay(dteNow) >= intDay, 7, 0)) + #8:00:00 AM#
-
Debug.Print dteNew
-
FutureDate = DateDiff("h", dteNow, dteNew)
-
-
End Function
-
HTH - Imboden This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: asreryll |
last post by:
I wish to show a future date in a table, so that I can sort and know
which case is in need of a review. I can display a future date in a
form but I want to see all records that are due on a certain date.
Any help would be appreciated.
Regards
G.K.
|
by: ROSY |
last post by:
1.How to make self deletable .exe file such that during runtime the file delete
itself from the current path.
plz answer,
thanks in advence.
bye.
|
by: rohayre |
last post by:
Im a long time java developer and actually have never done anything
with java scripting. I'd like to write a short simple script for
calculating a date in the future based on today's date and a letter.
Can I use javascripting to create a webpage to allow a user to enter a
letter and then click a button to find a future calendar date? I'm just...
|
by: Kevin |
last post by:
I have a simple application that handles authentication, and one of the
things it checks is password aging. If I have something like this:
If ("02/14/2007" <= Date.Today.ToString("MM/dd/yyyy")) Then
Messagebox.Show("Date specified is less than current")
Else
Messagebox.Show("Date specified is greater than current")
End If
|
by: bloukopkoggelmander |
last post by:
Hi all
Right, I dont know if this is possible in Access (2007) or not but here goes.
I want to create a form for a vehicle delivery where a user completes say half of it before delivery of the vehicle, set a future delivery date and then save it.
When this future date is then due, I would like Access to flag up to the user that this...
| |
by: =?Utf-8?B?Sm9ubnk=?= |
last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange
server using WEBDAV. It allows the users to look up appointments for a
future date. The problem I have is determining the correct client time zone.
Note that Exchange stores everything in UTC time.
I am able currently able to use javascript to ask the client what time...
|
by: dkyadav80 |
last post by:
Hi Sir,
I'm begener in Ajax or Javascript.I have problem about date validation.
I have 3 field in html page: 1->date(numeric), 2->month(text 1st 3 letter)
3->year(numeric). I wanna implement to validation through javascript. If user
enter future date then massege should be display "future date not allowed".
Please solve my problem.
Thank...
|
by: drrajnishpatel via AccessMonster.com |
last post by:
Dear Friends i am trying to get a future date as follows,
data:1) date of proceeding to leave = D
2) number of days leave sanctioned =N
3) date of reporting for duty =R
i grant "n" number of days leave to someone from"date of Leave" , so "R" the
reporting back date = "D"date of Leave + " 'N' no. of days leave granted",
this should happen...
|
by: jmartmem |
last post by:
Greetings,
I have an ASP page with a form (form1) that contains a JavaScript validation function that is activated onSubmit. The function contains a series of IF statements to alert the user to any blanks contained in the form elements.
What I want to do is add a new IF statement to the function that checks whether the user has populated a...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |