How to check a cell value is a date ?

L

L.Peter

Dear Group,
how can i determine a cell value is date value? : i.e
3/1/2004 returns .t.
March 1st 2004 return .t. (this one is optional, would be nice if it
can be evaluated)
TIA

Peter
 
N

Norman Harker

Hi L.Peter!

You need a UDF

Function ISADATE(MyCell As Range)
ISADATE = IsDate(MyCell)
End Function

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
F

Frank Kabel

Hi Peter
you'll need VBA for this. You may try the following UDF
Function Is_Date(Cell As Range) as boolean
Is_Date = IsDate(Cell)
End Function

Use this function an a cell like
=Is_Date(A1)
 
L

L.Peter

Thanks Norman,
I was hoping to get a quick way to solve this problem, any way, it just
takes a bit longer as I have to do it manually

Best Regards

Peter
 
L

L.Peter

Thanks Frank,
It works

Best Regards

Peter
Frank Kabel said:
Hi Peter
you'll need VBA for this. You may try the following UDF
Function Is_Date(Cell As Range) as boolean
Is_Date = IsDate(Cell)
End Function

Use this function an a cell like
=Is_Date(A1)
 
H

Harlan Grove

L.Peter said:
how can i determine a cell value is date value? : i.e
3/1/2004 returns .t.
March 1st 2004 return .t. (this one is optional, would be nice if it
can be evaluated)

Can be done without udfs. If you want to check for both date values and text
strings that could be converted directly into date values, try

=((ISNUMBER(1/A1/(LEFT(CELL("Format",A1),1)="D"))+ISNUMBER(DATEVALUE(A1)))>0
)

For date values only, try

=ISNUMBER(1/A1/(LEFT(CELL("Format",A1),1)="D"))
 
F

Frank Kabel

Harlan said:
Can be done without udfs. If you want to check for both date values
and text strings that could be converted directly into date values,
try

=((ISNUMBER(1/A1/(LEFT(CELL("Format",A1),1)="D"))+ISNUMBER(DATEVALUE(A1
)))>0
)

For date values only, try

=ISNUMBER(1/A1/(LEFT(CELL("Format",A1),1)="D"))

Hi Harlan
nice one!
Frank
 

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

Top