Hi, All,

I need to check if the date values is valid this current year, for example, February 29, 2012, I have used Isdate function but it says "True", is there any other way to do this?

Thanks in advance.


Recommended Answers

All 5 Replies

You can use the Year property of a date to get the year number and compare it to the current year.

Thanks Jim, I'll try it, is this the best way?

It depends on how you define "valid". If your intention is to see if it is a date in the current year, then I believe it is the easiest way.

I realize you have marked this thread solved, but you do realize that your example is a valid date don't you? 2012 is a leap year, hence IsDate(" February 29, 2012") will return true.

IsDate("February 30, 2012") would return false.

That's why I asked about the specific definition of "valid" in this context. It would also depend on the input method. For example, if it was a date from a datepicker then picking Feb 30 would never be an option.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.