473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Time Compare Function Problems

Could you look at this function and tell me why I am getting an
exception concerning date cast on line set apart by stars... If you have
better suggestions of how to do this I would be open to suggestions.
Public Function JobStreamCheck() As Boolean
Dim hour As Integer
Dim day As Integer
Dim year As Integer
Dim month As Integer
Dim ActionTime As DateTime 'time action is occuring that we are
checking to make sure no jobstream is running. Time obtained from SQL
using GetDate 'formatted as say for example 4:15 PM . Start and End
Times are also gotten from SQL but for this example they are declared
locally

Dim JobStreamStart As DateTime
Dim jobstreamend As DateTime

month = Format(ActionTime, "MM")
hour = Format(ActionTime, "HH")
day = Format(ActionTime, "dd")
year = Format(ActionTime, "yyyy")

JobStreamStart = Format(JobStreamStart, month & "/" & day & "/"
& year & " hh:mm tt")

If Format(JobStreamEnd, "HH:mm tt") > Format("23:59 PM", "HH:mm
tt") Then
JobStreamEnd = (JobStreamEnd, month & "/" & day + 1 & "/" &
year & " HH:mm tt")) 'move day ahead one because job stream will be in
new day
Else
'********EXCEPTION THROWN
jobstreamend = Format(jobstreamend, month & "/" & day & "/"
& year & " HH:mm tt") 'job stream will finish in same day
'*******EXCEPTION THROWN END
End If

If ActionTime >= JobStreamStart And ActionTime < jobstreamend
Then
Return True ' Job stream is running dont allow login
Else

Return False ' job stream is not running so allow login
End If
End Function

Nov 21 '05 #1
3 1261
Problem solved. Thanks.

"scorpion53061" <sc************@nospamhereyahoo.com> wrote in message
news:sc************@nospamhereyahoo.com:
Could you look at this function and tell me why I am getting an
exception concerning date cast on line set apart by stars... If you have

better suggestions of how to do this I would be open to suggestions.
Public Function JobStreamCheck() As Boolean
Dim hour As Integer
Dim day As Integer
Dim year As Integer
Dim month As Integer
Dim ActionTime As DateTime 'time action is occuring that we are
checking to make sure no jobstream is running. Time obtained from SQL
using GetDate 'formatted as say for example 4:15 PM . Start and End
Times are also gotten from SQL but for this example they are declared
locally

Dim JobStreamStart As DateTime
Dim jobstreamend As DateTime

month = Format(ActionTime, "MM")
hour = Format(ActionTime, "HH")
day = Format(ActionTime, "dd")
year = Format(ActionTime, "yyyy")

JobStreamStart = Format(JobStreamStart, month & "/" & day & "/"
& year & " hh:mm tt")

If Format(JobStreamEnd, "HH:mm tt") > Format("23:59 PM", "HH:mm
tt") Then
JobStreamEnd = (JobStreamEnd, month & "/" & day + 1 & "/" &
year & " HH:mm tt")) 'move day ahead one because job stream will be in
new day
Else
'********EXCEPTION THROWN
jobstreamend = Format(jobstreamend, month & "/" & day & "/"
& year & " HH:mm tt") 'job stream will finish in same day
'*******EXCEPTION THROWN END
End If

If ActionTime >= JobStreamStart And ActionTime < jobstreamend
Then
Return True ' Job stream is running dont allow login
Else

Return False ' job stream is not running so allow login
End If
End Function


Nov 21 '05 #2
Scorpion,
I would (still) recommend a TimeRange as identified in my response the last
time you asked this question:

http://groups-beta.google.com/group/...1fe04f3c?hl=en

Then the JobStreamCheck routine becomes:

Public Function JobStreamCheck() As Boolean
Dim ActionTime As DateTime = ...

Dim JobStreamStart As DateTime = ...
Dim JobStreamEnd As DateTime = ...

Dim JobStreamRange As New TimeRange(JobStreamStart, JobStreamEnd)

If JobStreamRange.Contains(ActionTime) Then
Return True
Else
Return False
End If

End Function

Hope this helps
Jay

"scorpion53061" <sc************@nospamhereyahoo.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
| Could you look at this function and tell me why I am getting an
| exception concerning date cast on line set apart by stars... If you have
| better suggestions of how to do this I would be open to suggestions.
|
|
| Public Function JobStreamCheck() As Boolean
| Dim hour As Integer
| Dim day As Integer
| Dim year As Integer
| Dim month As Integer
| Dim ActionTime As DateTime 'time action is occuring that we are
| checking to make sure no jobstream is running. Time obtained from SQL
| using GetDate 'formatted as say for example 4:15 PM . Start and End
| Times are also gotten from SQL but for this example they are declared
| locally
|
| Dim JobStreamStart As DateTime
| Dim jobstreamend As DateTime
|
| month = Format(ActionTime, "MM")
| hour = Format(ActionTime, "HH")
| day = Format(ActionTime, "dd")
| year = Format(ActionTime, "yyyy")
|
| JobStreamStart = Format(JobStreamStart, month & "/" & day & "/"
| & year & " hh:mm tt")
|
| If Format(JobStreamEnd, "HH:mm tt") > Format("23:59 PM", "HH:mm
| tt") Then
| JobStreamEnd = (JobStreamEnd, month & "/" & day + 1 & "/" &
| year & " HH:mm tt")) 'move day ahead one because job stream will be in
| new day
| Else
| '********EXCEPTION THROWN
| jobstreamend = Format(jobstreamend, month & "/" & day & "/"
| & year & " HH:mm tt") 'job stream will finish in same day
| '*******EXCEPTION THROWN END
| End If
|
| If ActionTime >= JobStreamStart And ActionTime < jobstreamend
| Then
| Return True ' Job stream is running dont allow login
| Else
|
| Return False ' job stream is not running so allow login
| End If
| End Function
|
Nov 21 '05 #3

Jay,

In fact I looked in my archive and sure enough it was there. Turned out
I had lost the project it was in.

Thank you much.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message news:Ja************@msn.com:
Scorpion,
I would (still) recommend a TimeRange as identified in my response the
last
time you asked this question:
http://groups-beta.google.com/group/...nguages.vb/msg
/2eaea1681fe04f3c?hl=en

Then the JobStreamCheck routine becomes:

Public Function JobStreamCheck() As Boolean
Dim ActionTime As DateTime = ...

Dim JobStreamStart As DateTime = ...
Dim JobStreamEnd As DateTime = ...

Dim JobStreamRange As New TimeRange(JobStreamStart,
JobStreamEnd)

If JobStreamRange.Contains(ActionTime) Then
Return True
Else
Return False
End If

End Function

Hope this helps
Jay

"scorpion53061" <sc************@nospamhereyahoo.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
| Could you look at this function and tell me why I am getting an
| exception concerning date cast on line set apart by stars... If you
have
| better suggestions of how to do this I would be open to suggestions.
|
|
| Public Function JobStreamCheck() As Boolean
| Dim hour As Integer
| Dim day As Integer
| Dim year As Integer
| Dim month As Integer
| Dim ActionTime As DateTime 'time action is occuring that we are
| checking to make sure no jobstream is running. Time obtained from SQL
| using GetDate 'formatted as say for example 4:15 PM . Start and End
| Times are also gotten from SQL but for this example they are declared
| locally
|
| Dim JobStreamStart As DateTime
| Dim jobstreamend As DateTime
|
| month = Format(ActionTime, "MM")
| hour = Format(ActionTime, "HH")
| day = Format(ActionTime, "dd")
| year = Format(ActionTime, "yyyy")
|
| JobStreamStart = Format(JobStreamStart, month & "/" & day & "/"
| & year & " hh:mm tt")
|
| If Format(JobStreamEnd, "HH:mm tt") > Format("23:59 PM", "HH:mm
| tt") Then
| JobStreamEnd = (JobStreamEnd, month & "/" & day + 1 & "/" &
| year & " HH:mm tt")) 'move day ahead one because job stream will be in
| new day
| Else
| '********EXCEPTION THROWN
| jobstreamend = Format(jobstreamend, month & "/" & day & "/"
| & year & " HH:mm tt") 'job stream will finish in same day
| '*******EXCEPTION THROWN END
| End If
|
| If ActionTime >= JobStreamStart And ActionTime < jobstreamend
| Then
| Return True ' Job stream is running dont allow login
| Else
|
| Return False ' job stream is not running so allow login
| End If
| End Function
|


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: laniik | last post by:
Hi. I have a problem using STL's built in sort that seems impossible to get around. if i have: -------------------------------- struct object { int val; }
6
by: teddysnips | last post by:
I have a table called WorkItem. It models a chunk of work done during a working day. It has two columns that I'm interested in: Start (smalldatetime) - the TIME the work block is begun...
1
by: gi75research | last post by:
What should be a very simple function is going terribly wrong, and I don't know why. StartTime and EndTime are table values (formatted like "01:00A" or "02:00P"); DaypartStart and DaypartEnd are...
5
by: galsaba | last post by:
How can I find how many time a string appears in a text. Is there a function in access that does it? For example, text: "My name is John Smith, and my wife is Katy Smith" HowMany(text, "Smith")...
10
by: scorpion53061 | last post by:
What I thought would be pretty easy has turned out not to be. I have three variables. Actiontime is formatted as 08/11/2004 11:03PM Actiontime JobStreamStart (11:00:00PM) JobStreamEnd...
6
by: SJ | last post by:
howdy, In vb6 I could say If Time >#4:00:00 PM# And Time < #4:01:00 PM# Then 'Do Something End If Well, I don't see the Time function in vb.net. I have experimented with the TimeSpan...
3
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And...
7
by: gabitoju | last post by:
I have to hours like this 20:30:15 (HH:MM:SS) loeaded in two std:string, and I wan't to compare them. I looked at ctime but I didn't found, first, somethig to convert from string to time and then...
25
by: Brian | last post by:
I have a datetimepicker formated for just time, the user selects the time. I want to compare if that time is between midnight and 8 am dtmTime #11:59:59 PM# and dtmTime < #08:00:00 AM# this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.