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 2040
On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospam.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",Now(),#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******@nospam.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",Now(),#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******@nospam.com> wrote in message
news:5M****************@fe1.columbus.rr.com... Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospam.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",Now(),#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******@nospam.com> wrote in message news:<5M****************@fe1.columbus.rr.com>... Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospam.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",Now(),#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********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>... HateSpam <Ha******@nospam.com> wrote in message news:<5M****************@fe1.columbus.rr.com>... Jim Allensworth wrote: On Thu, 09 Sep 2004 22:27:40 GMT, HateSpam <Ha******@nospam.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",Now(),#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...
|
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...
|
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"))...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |