Solved

How to compare date without time portion?

Posted on 2008-09-30
2
978 Views
Last Modified: 2008-09-30
I am comparing a date entered in a textbox with DateTime.Now. If date by user is today, the comparison

if (txtDate.text > DateTime.Now) is true. My guess is that the time portion of txt entered is today midnight.

What's the best to do date comparison without using the time portion?
0
Comment
Question by:jentel2
  • 2
2 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 22606238
DateTime.Now.Date
0
 
LVL 22

Accepted Solution

by:
p_davis earned 500 total points
ID: 22606248
if(Convert.ToDateTime(txtDate.text).Date > DateTime.Now.Date)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on link 14 46
Device Location 4 29
HTML - Color not displaying correctly in EMAIL. 6 35
What Does This C# Code Block Do? 5 26
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question