Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 December 20th, 2007, 01:42 AM
Authorized User
Join Date: Dec 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dharmeshtandel
Default Date comparision in asp.net

Dear All,
I have a problem regarding the dates.
i want to compare a two dates in asp.net2.0.
i want to check whether the second date is greater then firstdate.
so which validator control i will used in this situation and how?.
please give me the positive reply if any..

Dharmesh Tandel

Old December 20th, 2007, 04:32 AM
Friend of Wrox
Join Date: Aug 2006
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post

well i feel compare validator may not solve yours problem its better to check it in code as if(firstdate > seconddate)

Old December 20th, 2007, 09:45 AM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Use DateTime.Compare()

================================================== =========
Read this if you want to know how to get a correct reply for your question:
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
Old December 20th, 2007, 03:17 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

From MSDN CompareValidator Members:

"Type: Gets or sets the data type that the values being compared are converted to before the comparison is made. (Inherited from BaseCompareValidator.)"

Set it to DateTime and it will use the standard DateTime comparer.

Old December 22nd, 2007, 02:20 PM
Registered User
Join Date: Dec 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Dharmaesh

Date Comparison can be done with Compare Validator
Just Add Compare Validator .In Properties Select Type=Date
Operator=Greater (as u require from drop down) and Fill Up
Control To Compare and Control To Validate

Hope this works



Similar Threads
Thread Thread Starter Forum Replies Last Post
Date problem in asp.net 1.1 kalpesh.mahajan ASP.NET 1.0 and 1.1 Basics 0 August 14th, 2006 07:45 AM
C#(ASP.NET) Validate date entry richie86 ASP.NET 1.0 and 1.1 Basics 1 November 3rd, 2005 01:58 AM
How to post the date to another page ASP.NET? rpkarthic ASP.NET 1.x and 2.0 Application Design 1 August 12th, 2005 04:06 AM
Setting date format from ASP.NET jonashilmersson Crystal Reports 0 November 14th, 2003 04:14 AM

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