| View previous topic :: View next topic |
| Author |
Message |
topher General User

Joined: 29 Sep 2004 Posts: 12
|
Posted: Wed Sep 29, 2004 7:54 pm Post subject: How to detect an invalid date format in a cell? |
|
|
Can anyone give me a sample code on how to detect if a date in a cell is not in a e.g. 9/30/04 format. I want to detect invalid entries like letters and numbers (e.g. werer, 24434 etc.) and invalid dates like 9/36/04 and invalid formats like 9-3-04.
t.y. |
|
| Back to top |
|
 |
r_vinoya Super User


Joined: 03 Dec 2003 Posts: 619 Location: Somewhere in the Philippines
|
Posted: Thu Sep 30, 2004 12:42 am Post subject: Re: How to detect an invalid date format in a cell? |
|
|
| topher wrote: | Can anyone give me a sample code on how to detect if a date in a cell is not in a e.g. 9/30/04 format. I want to detect invalid entries like letters and numbers (e.g. werer, 24434 etc.) and invalid dates like 9/36/04 and invalid formats like 9-3-04.
t.y. |
Hello topher,
Try this:
To check is date is valid:
| Code: | | PRINT ISDATE(thiscomponent.sheets(0).getcellbyposition(0,0).string) 'returns True if Sheet1.A1 is a valid date entry, text entry |
To check if format is invalid:
For Format M/DD/YY:
| Code: | If thiscomponent.sheets(0).getcellbyposition(0,0).numberformat<>106 then
print "invalid format"
endif |
Note: You can try experimenting with different numberformat and print it: (msgbox thiscomponent.sheets(0).getcellbyposition(0,0).numberformat) to get the desired code. _________________ # : - ) |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|