dates

  • Thread starter Thread starter DaveP
  • Start date Start date
D

DaveP

how to validate a date type
is there a isdate() function in c#
or do i write my own

DaveP
 
DaveP said:
how to validate a date type
is there a isdate() function in c#
or do i write my own

What date type? DateTime? A DateTime instance is always a valid date
and time, though it may fall outside of some range you require.

Or do you mean you want to validate a string to verify it represents an
actual date? You could use DateTime.TryParse() to do that, though of
course there are a wide variety of strings that a human could recognize
as a date but which would fail to be parsed. Still, using TryParse()
should give you results useful in a computer program. :)

Pete
 
DaveP said:
how to validate a date type
is there a isdate() function in c#
or do i write my own

What are you looking for ?

A DateTime type is a DateTime type.

Are you looking to test whether a string contains
a valid date according to either standard formats
or a custom format ?

If that is the case try look at DateTime Parse and
ParseExact methods (or TryParse and TryParseExact).

Arne
 
thats what i used is datetime.parse()
so much in .net....wasn't sure if there was a function out there somewhere

Thank you much
DaveP
 
DaveP said:
thats what i used is datetime.parse()
so much in .net....wasn't sure if there was a function out there somewhere

If you use a non standard format then you may need the Exact variants.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DLL and Application Config 1
is this a bug in net 2.0 6
Pessimistic locking 1
resolve ip address 3
how To Talk to a vb6 window from c# 1
dll paths 3
service 2
Calling C#Dll from Vb6 7

Back
Top