0

I am just comparing 2 dates.

C#

  string args = string.Format("'{0}','{1}'
                            ,(DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue
                            , DateTime.Now);

        add.OnClientClick = String.Format("JSFunctn1({0}); return false;", args);

Js File:

JSFunctn1(maxDate, currentDate)
{
alert(maxDate);
alert(currentDate); // Both Dates displayed properly

if (currentDate >= maxDate) {
        alert("error"); //IT Comes here
    }

Can anyone tell me where am I wrong, It should not come in the loop, because max Date is 12/31/9999 12:00:00 AM

2
  • What are the values you see in maxDate and currentDate at client end ? Commented Jun 4, 2015 at 18:11
  • I wrote the maxDate : 12/31/9999 12:00:00 AM and currentDate is the currentTime; 6/4/2015 2:00:00 PM Commented Jun 4, 2015 at 18:21

1 Answer 1

1

I suspect the problem is that you are comparing strings rather than dates.

Try this on the client:

if (Date.parse(currentDate) >= Date.parse(maxDate)) {
  alert('error');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.