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 evaluates to true when the time is not greater than
dtmTime #9:32:34 PM#
Why is that? and How can I get this to work?
Brian 25 4523
Brian,
Maybe it is more simple (at least for me, not somebody from an English
culture), to use New Datetime.
dim a (as DateTime for older versions) = new DateTime(now.Ye ar,now.Month,
Now,Day,8,0,0)
If a < Now then it is behind 8 o'clcok
Cor
"Brian" <bs********@com munity.nospamsc hreef in bericht
news:Oi******** ******@TK2MSFTN GP04.phx.gbl...
>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 evaluates to true when the time is not greater than
dtmTime #9:32:34 PM#
Why is that? and How can I get this to work?
Brian
not really sure what you mean there.. I have dtmTime defined as datetime
and when I do immed on it.. is
#11/5/2008 9:44:07 PM# but in my code posted previously... this was
evaluating to than midnight
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:O3******** ******@TK2MSFTN GP04.phx.gbl...
Brian,
Maybe it is more simple (at least for me, not somebody from an English
culture), to use New Datetime.
dim a (as DateTime for older versions) = new DateTime(now.Ye ar,now.Month,
Now,Day,8,0,0)
If a < Now then it is behind 8 o'clcok
Cor
"Brian" <bs********@com munity.nospamsc hreef in bericht
news:Oi******** ******@TK2MSFTN GP04.phx.gbl...
>>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 evaluates to true when the time is not greater than
dtmTime #9:32:34 PM#
Why is that? and How can I get this to work? Brian
"Brian" <bs********@com munity.nospamsc hrieb
not really sure what you mean there.. I have dtmTime defined as datetime
and when I do immed on it.. is
#11/5/2008 9:44:07 PM# but in my code posted previously... this was
evaluating to than midnight
Isn't everything than midnight?
Try comparing the TimeOfDay only (YourDateTimePi cker.Value.Time OfDay)
Armin
this is what i get using the timeofday....
Overload resolution failed because no accessible '>' can be called with
these arguments:
'Public Shared Operator >(t1 As Date, t2 As Date) As Boolean': Value of type
'System.TimeSpa n' cannot be converted to 'Date'.
'Public Shared Operator >(t1 As System.TimeSpan , t2 As System.TimeSpan ) As
Boolean': Value of type 'Date' cannot be converted to 'System.TimeSpa n'.
If dtmTime #11:59:59 PM# And dtmTime < #08:00# Then
I would like for that to be true if the dtmTime is between those times..
otherwise false... dtmTime is defined as DateTime
"Armin Zingler" <az*******@free net.dewrote in message
news:ey******** ******@TK2MSFTN GP05.phx.gbl...
"Brian" <bs********@com munity.nospamsc hrieb
>not really sure what you mean there.. I have dtmTime defined as datetime and when I do immed on it.. is #11/5/2008 9:44:07 PM# but in my code posted previously... this was evaluating to than midnight
Isn't everything than midnight?
Try comparing the TimeOfDay only (YourDateTimePi cker.Value.Time OfDay)
Armin
Hello, Brian,
I'm a bit confused about what you are trying to do.
Re: "...formate d for just time,"
As far as I know, the value returned by the DateTimePicker will include the
date even if the display is formatted to show only time. Perhaps your
problem is that you still need to truncate that date.
Re: "dtmTime #11:59:59 PM# and dtmTime < #08:00:00 AM#"
You say this evaluates to True. But I think that there are not many (by
that I mean any) times for which the above statement would evaluate to True.
Don't you just want the second half of that statement. I.e.: "dtmTime <
#08:00:00 AM#"
Cheers,
Randy
I thought you did want every time behind 8 0'clock today.
But It is simple from this code that it goes only for today
I had first
dim b = new DateTime(New DateTime(now.Ye ar,now.Month, Now,Day, 24,0,0)
dim a (as DateTime for older versions) = new DateTime(now.Ye ar,now.Month,
Now,Day,8,0,0)
If a < Now and also Now < B then it is between 8 and 24 o'clock
Cor
"Brian" <bs********@com munity.nospamwr ote in message
news:ua******** ******@TK2MSFTN GP05.phx.gbl...
not really sure what you mean there.. I have dtmTime defined as datetime
and when I do immed on it.. is
#11/5/2008 9:44:07 PM# but in my code posted previously... this was
evaluating to than midnight
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:O3******** ******@TK2MSFTN GP04.phx.gbl...
>Brian,
Maybe it is more simple (at least for me, not somebody from an English culture), to use New Datetime.
dim a (as DateTime for older versions) = new DateTime(now.Ye ar,now.Month, Now,Day,8,0, 0)
If a < Now then it is behind 8 o'clcok
Cor
"Brian" <bs********@com munity.nospamsc hreef in bericht news:Oi******* *******@TK2MSFT NGP04.phx.gbl.. .
>>>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 evaluates to true when the time is not greater than
dtmTime #9:32:34 PM#
Why is that? and How can I get this to work? Brian
well no, I want any time that is between midnight and 8am to be true...
"OmegaSquar ed" <Om**********@d iscussions.micr osoft.comwrote in message
news:F4******** *************** ***********@mic rosoft.com...
Hello, Brian,
I'm a bit confused about what you are trying to do.
Re: "...formate d for just time,"
As far as I know, the value returned by the DateTimePicker will include
the
date even if the display is formatted to show only time. Perhaps your
problem is that you still need to truncate that date.
Re: "dtmTime #11:59:59 PM# and dtmTime < #08:00:00 AM#"
You say this evaluates to True. But I think that there are not many (by
that I mean any) times for which the above statement would evaluate to
True.
Don't you just want the second half of that statement. I.e.: "dtmTime <
#08:00:00 AM#"
Cheers,
Randy
"Brian" <bs********@com munity.nospamsc hrieb
this is what i get using the timeofday....
Overload resolution failed because no accessible '>' can be called
with these arguments:
'Public Shared Operator >(t1 As Date, t2 As Date) As Boolean': Value
of type 'System.TimeSpa n' cannot be converted to 'Date'.
'Public Shared Operator >(t1 As System.TimeSpan , t2 As
System.TimeSpan ) As Boolean': Value of type 'Date' cannot be
converted to 'System.TimeSpa n'.
If dtmTime #11:59:59 PM# And dtmTime < #08:00# Then
I would like for that to be true if the dtmTime is between those
times.. otherwise false... dtmTime is defined as DateTime
If dtmTime is a DateTime object, the last line should be compilable.
#11:59:59 PM# is actually 01/01/0001 11:59:59 PM and
#08:00# is actually 01/01/0001 08:00 AM
However, you want to compare times, not points in time. A TimeSpan object is
usually used to represent the time of a day, like the TimeOfDay property of
a DateTime object shows. It's the timespan from midnight until the time
given.
So, dtmTime should be a TimeSpan variable. Then the statement is:
If dtmTime New TimeSpan AndAlso dtmTime < New TimeSpan(8, 0, 0) Then
Instead of
dtmTime New TimeSpan
you can also use
dtmTime.Ticks 0
or
dtmTime New Timespan(0)
or
...
I don't know if midnight is to be included or excluded. It it's included,
the first expression is not required at all because ever time is equal to or
after midnight.
Armin
ok, i guess i am just not getting.. let me rephase what I am doing and you
tell me what is best to here
i have a function that accepts to varibles.. dtmdate as date, dtmTime as
date
Public Function GetShift(ByVal dtmDate As Date, ByVal dtmTime As DateTime)
As String
If dtmTime #11:59:59 PM# And dtmTime < ShiftEndTime Then
strShift = "N"
dtmDate.AddDays (-1)
End If
return getshift(dtmDat e, "N")
Now, if this function is ran between midnight and 8 am then I subtract 1 day
to get the team that started its night shift the previous day.
Not sure i am having a hard time understanding.. maybe i need a
vacation...lol
"Cor Ligthert[MVP]" <No************ @planet.nlwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
>I thought you did want every time behind 8 0'clock today.
But It is simple from this code that it goes only for today
I had first
dim b = new DateTime(New DateTime(now.Ye ar,now.Month, Now,Day, 24,0,0)
dim a (as DateTime for older versions) = new DateTime(now.Ye ar,now.Month,
Now,Day,8,0,0)
If a < Now and also Now < B then it is between 8 and 24 o'clock
Cor
"Brian" <bs********@com munity.nospamwr ote in message
news:ua******** ******@TK2MSFTN GP05.phx.gbl...
>not really sure what you mean there.. I have dtmTime defined as datetime and when I do immed on it.. is #11/5/2008 9:44:07 PM# but in my code posted previously... this was evaluating to than midnight
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message news:O3******* *******@TK2MSFT NGP04.phx.gbl.. .
>>Brian,
Maybe it is more simple (at least for me, not somebody from an English culture), to use New Datetime.
dim a (as DateTime for older versions) = new DateTime(now. Year,now.Month, Now,Day,8,0,0)
If a < Now then it is behind 8 o'clcok
Cor
"Brian" <bs********@com munity.nospamsc hreef in bericht news:Oi****** ********@TK2MSF TNGP04.phx.gbl. .. 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 evaluates to true when the time is not greater than
dtmTime #9:32:34 PM#
Why is that? and How can I get this to work? Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Javier |
last post by:
Hi
I´ve a routine that will read date and times in a vector of strings ie:
30/02/2005 19:20
In some moment I´ll need to check if there are in vector a date like
current date with a time >= current time and <= (current time + n minutes)
|
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
Duration (int) - the duration in minutes of the work block.
In another table called OvertimeRates I have information about rate
multipliers and a...
|
by: wrytat |
last post by:
I have a table in my database that has a DateTime field that stores a time
that I want to compare with the current time in my asp.net vb codes.
The value stored in the field is for example, 01/01/1900 11:00:00. So
actually I'm only interested with 11:00 am. And let's say the time I want to
compare with is 26/09/2005 08:06:05; then I would...
|
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 (2:00:00AM)
If (Format(CDate(ActionTime), "t") >= JobStreamStart AND
(Format(CDate(ActionTime), "t") < jobstreamend Then
|
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 object for capturing
| |
by: Prabhudhas Peter |
last post by:
I have two object instances of a same class...
and i assigned values in both object instances (or the values can be taken
from databse and assigned to the members of the objects)...
Now i want to compare these two objects so that it will return true if both
object's members have the same value...
it is good if u can give me a single function...
|
by: Robm |
last post by:
Since googling this issue only brings up the April fool's problem, which was
solved years ago, I hope that somebody can help me with this. I have a large
vc++/mfc application which needs to know when DST is in effect. This has
been working fine for years, but I am worried about the upcoming change in
2007 in the US, which will be followed by a...
|
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 to be able to do
comparisons on them.
|
by: FFMG |
last post by:
In my site I have a config table, (MySQL), with about 30 entries; the
data is loaded on every single page load. This is not the only call to
the db, (we do a total of about 8 calls to the db).
As with many configurations settings, once the options are set the
values will not change much.
So I thought it would be a good idea to move the data...
|
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: 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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |