Hello,
I was wondering what the easiest way is to compare two DateTime objects and
not have the time components be included in the comparision.
For, example, if time1 = 10/01/07 9:00 am, and time2 = 10/1/07 10:00 am,
time1.CompareTo (time2) == 0 should evaluate to true.
Thanks,
Chris 3 6224
On Oct 1, 11:42 am, "ChrisB" <pleasereplytog r...@thanks.com wrote:
Hello,
I was wondering what the easiest way is to compare two DateTime objects and
not have the time components be included in the comparision.
For, example, if time1 = 10/01/07 9:00 am, and time2 = 10/1/07 10:00 am,
time1.CompareTo (time2) == 0 should evaluate to true.
Thanks,
Chris
Hi Chris,
I would just compare the .Date properties:
DateTime dt1 = new DateTime(2007, 10, 1, 10, 0, 0);
DateTime dt2 = new DateTime(2007, 10, 1, 9, 0, 0);
TimeSpan ts = dt1.Date - dt2.Date;
bool sameDate = (ts == TimeSpan.Zero);
John
Chris,
You would use time1.Date.Comp areTo(time2.Dat e) == 0
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"ChrisB" <pl************ ****@thanks.com wrote in message
news:OB******** ******@TK2MSFTN GP04.phx.gbl...
Hello,
I was wondering what the easiest way is to compare two DateTime objects
and not have the time components be included in the comparision.
For, example, if time1 = 10/01/07 9:00 am, and time2 = 10/1/07 10:00 am,
time1.CompareTo (time2) == 0 should evaluate to true.
Thanks,
Chris
Thanks, Nicholas. That did the job.
Chris
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:uX******** ******@TK2MSFTN GP03.phx.gbl...
Chris,
You would use time1.Date.Comp areTo(time2.Dat e) == 0
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"ChrisB" <pl************ ****@thanks.com wrote in message
news:OB******** ******@TK2MSFTN GP04.phx.gbl...
>Hello,
I was wondering what the easiest way is to compare two DateTime objects and not have the time components be included in the comparision.
For, example, if time1 = 10/01/07 9:00 am, and time2 = 10/1/07 10:00 am, time1.CompareT o(time2) == 0 should evaluate to true.
Thanks, Chris
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: PAUL MENARD |
last post by:
--0-930715088-1061086093=:22602
Content-Type: text/plain; charset=us-ascii
Hello All,
I'm having trouble understanding the MySQL docs on how to subtract two DATETIME values. I have two tables that have a DATETIME column. In my SELECT I am doing a JOIN to bring in both sets of rows. What I want is to subtract the DATETIME values to determine the number of seconds between their time. In the WHERE clause I also want to filter the selected...
|
by: Dirk Reske |
last post by:
Hello,
I have two dates.
How can I check if the second date is the day after the first date?
thx
--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
|
by: SenthilVel |
last post by:
HI
how to get the differences between 2 given dates??
supposse if i ahve 2 dates , DATEa, and current datetime.
how can i find if the DATEa is less then 3 hrs from the current datetime ???
,,,,
|
by: Tom |
last post by:
It appears that you can't compare two dates in DotNet. You must use
ToString and compare the strings. Is that the only reliable way?
Try this:
Dim dteOne As Date = FileDateTime(Application.ExecutablePath)
Dim dteTwo As Date = FileDateTime(Application.ExecutablePath)
SaveSetting("Test", "Dates", "DateThree",
FileDateTime(Application.ExecutablePath))
Dim dteThree As Date = CDate(GetSetting("Test", "Dates",
|
by: Mika M |
last post by:
I need to compare two DateTime variables named as t1 and t2 using VB.NET
2003. If t1 is any earlier time as t2, only then program should do
something like...
If (t1 < t2) Then
'DoSomethingHere...
End If
But I don't figue out how comparing DateTimes is working.
| |
by: Tim Cowan |
last post by:
Hi,
In my application I need to compare whether one time is greater than
another. What I am doing right now is taking the current datetime,
formatting as string without the time element, and then appending the time I
want to the date and converting to date.
DateTime dOpen = System.Convert.ToDateTime(now.Date.ToString("MMM dd, yyyy")
+ " " + storeOpen.Hour + ":" + storeOpen.Minute);
|
by: Mark |
last post by:
I'd like to compare two datetime values in milliseconds. The
datetime.compare method appears to show only seconds. Milliseconds of a
datetime are available as a property of each datetime, but I am assuming
there is an easier way than comparing the milliseconds, seconds, minutes,
hours, days, etc, individually to generate the difference.
Thanks in advance.
Mark
|
by: PurpleServerMonkey |
last post by:
Hopefully a simple DateTime problem.
I've got a windows service created in C# on .Net Framework 2.0, the
service uses a system timer to fire an event every second and compare
that against a known time to fire off a worker thread. All the
DateTime objects are using local time as the services are local to the
server.
DateTime runAt = DateTime.Parse("4/24/2007 2:30:00 PM");
System.Timers.Timer _timer = new System.Timers.Timer();
|
by: =?Utf-8?B?U2FuZHBvaW50R3V5?= |
last post by:
string dateTime = "5/28/2008";
DateTime.Compare(DateTime.Now,DateTime.Now) // returns 0
DateTime.Compare(DateTime.Now,DateTime.Parse(dateTime)) // returns 1
I need to compare 2 dates, using the second format, and I
dont understand why it isnt returning 0
Thank you
|
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: 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: 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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |