string dateTime = "5/28/2008";
DateTime.Compar e(DateTime.Now, DateTime.Now) // returns 0
DateTime.Compar e(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 3 2741
SandpointGuy <Sa**********@d iscussions.micr osoft.comwrote:
string dateTime = "5/28/2008";
DateTime.Compar e(DateTime.Now, DateTime.Now) // returns 0
DateTime.Compar e(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
Because it's not midnight right now. If you only want to compare the
date components, use DateTime.Today.
--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
On May 28, 2:58*pm, SandpointGuy
<Sandpoint...@d iscussions.micr osoft.comwrote:
string dateTime = "5/28/2008";
DateTime.Compar e(DateTime.Now, DateTime.Now) // returns 0
DateTime.Compar e(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
Hi,
DateTme.Now include a time component.
Also it might be possible that the first line (using Now both times)
give also <>1, depending of how fast both evaluations are performed
DateTime.Now inclides current time also. In the string you did not
give the time, means it takes as midnight 12:00. So its quite
meaningful to get 1 returned.
instead try the following
string dateTime = "5/29/2008";
DateTime.Compar e(DateTime.Toda y, DateTime.Parse( dateTime)); //returns
0
Hope this should solve the issue that you are facing.
Thanks
Cnu
On May 28, 11:58*pm, SandpointGuy
<Sandpoint...@d iscussions.micr osoft.comwrote:
string dateTime = "5/28/2008";
DateTime.Compar e(DateTime.Now, DateTime.Now) // returns 0
DateTime.Compar e(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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sorisio, Chris |
last post by:
Ladies and gentlemen,
I've imported some data from a MySQL database into a Python dictionary. I'm
attempting to tidy up the date fields, but I'm receiving a
'mx.DateTime.Error: cannot convert value to a time value' error. It's
related to glibc returning an error to a pre-1970 date, I think.
My question: /how/ do I go through the Python direction I've created to
remove the pre-1970 date objects? Ideally, I would be able to iterate...
|
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: conckrish |
last post by:
Hi all..
Can anyone tell me how to compare datetime objects?I ve three
objects namely Current date,start date and end date.. I need to check
the current date with Start date and end date....Plz tell me how to
compare ???
Thanx..
Krish
|
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: Harold Crump |
last post by:
Greetings,
This is not strictly a ASP.NET question, but I am hoping someone can
help.
I have an ASP.NET web app that used the DateTime.Parse and Compare
methods a lot.
As expected, the Regional Settings/Culture on the server (Windows
Server 2003), affects the behaviour of those DateTime functions (date
| |
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: Matt Brown - identify |
last post by:
Hello,
I'm trying to figure out a method to look up by a range of dates,
entries in a database. The format of the date in the database is "M\D
\yyyy HH:MM:SS".
What i need to do is take the dates that are in the database
(formatted as above), isolate the date (which is in short format) and
compare it to the short formatted date in a datetimepicker.
|
by: ChrisB |
last post by:
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
|
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: 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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.
| |