0% found this document useful (0 votes)
14 views

Private Bool String Try: Validatedate (Date) ( ( Dateparts Date - Split

This method validates that a date string is in the proper MM/DD/YYYY format. It splits the date string on the '/' character, converts each part to an integer, and attempts to create a DateTime object from the values. If successful, it returns true, otherwise it returns false.

Uploaded by

aksharma36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Private Bool String Try: Validatedate (Date) ( ( Dateparts Date - Split

This method validates that a date string is in the proper MM/DD/YYYY format. It splits the date string on the '/' character, converts each part to an integer, and attempts to create a DateTime object from the values. If successful, it returns true, otherwise it returns false.

Uploaded by

aksharma36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

/// <summary>

/// Determine if Date String is an actual date


/// Date format = MM/DD/YYYY
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private bool ValidateDate(string date
!
try
!
// for "S# alter to suit if splitting on $yp$en# comma# etc%
string&' date(arts = date%Split()/)*
// create ne+ date from t$e parts* if t$is does not fail
// t$e met$od +ill return true and t$e date is valid
Date,ime testDate = ne+
Date,ime(-onvert%,o.nt/0(date(arts&0'#
-onvert%,o.nt/0(date(arts&1'#
-onvert%,o.nt/0(date(arts&2'*
return true*
3
catc$
!
// if a test date cannot be created# t$e
// met$od +ill return false
return false*
3
3

You might also like