Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2005, 05:39 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date comparison

Hi
How to compare the date entered in the textbox having format dd/mm/yyyy with system date in .Net.I have to validate the date with system date so that the user should not be allowed to enter the date less than system date.My date format is dd/mm/yyyy.

Thanks and Regards.
Lily

 
Old January 3rd, 2005, 06:26 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Hi
   DateTime.Now will get you the system date.Properties like Month,Year,Day will give you the system date's month,day,year.You can check the entered date by extracting portions of the date(dd,mm,yyyy) with the system date's month,day,year..

 
Old January 3rd, 2005, 07:39 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am getting the system date in dd/mm/yyyy format but how to compare that with the entered date.I have to compare that the entered date must not be less than system date.

 
Old January 3rd, 2005, 08:44 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

One way is you can extract the portion of the day,month and year of both the dates and you can check..
Second way is convert the entered date to DateTime and use the DateTime.CompareTo function to check the entered date is less than System date.
Ex. result = Entererdate.CompareTo(SystemDate) .if result is less than 0,then entereddate is lesser.

 
Old January 4th, 2005, 01:10 AM
Authorized User
 
Join Date: Jul 2004
Location: chennai, tamilnadu, India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aravwind Send a message via Yahoo to aravwind
Default

You can also use DateDiff() function.
chk this in .NET SDK Framework help
 
Old January 4th, 2005, 07:08 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Yes lily you can use DateDiff also.If the difference is negative,then date is lesser.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Comparison jroxit Classic ASP Databases 5 October 5th, 2007 05:39 PM
Date comparison problem mat41 Javascript 3 August 30th, 2006 09:22 PM
Date comparison rajuru Beginning PHP 2 February 19th, 2005 10:33 AM
Date Comparison hoffmann Classic ASP Databases 7 October 21st, 2004 09:00 AM
Date Comparison cmiller PHP How-To 3 June 19th, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.