# Check if a valid date?

#### Guanjin Peter

##### Active Member
I'm currently using the below code to check if it's blank. Actually I wanted to check if it is a valid date. I can't really use:
=IF(B1=dd-mm-yyyy,TEXT(WEEKDAY(B1),"dddd"),"")
so any idea?

Code:
``=IF(B1="","",TEXT(WEEKDAY(B1),"dddd"))``

### Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

#### Joe4

Dates are actually stored as Numbers in Excel (specifically, the number of days since 1/1/1900). So you can use the ISNUMBER function, i.e.

=IF(ISNUMBER(B1),TEXT(WEEKDAY(B1),"dddd"),"")

#### Guanjin Peter

##### Active Member
there wasn't a need to specifcy true or false...that's strange.....

well it works wonders! Thanks!

It'll work for Vb code too?

like:
If Range("b1").Value = "ISNUMBER(B1)"

Last edited:

#### schielrn

##### Well-known Member
If it is a number it is presumed true and if it is not then it is presumed false.

In if statements =TRUE and =FALSE are not really needed., but you could put:

=IF(ISNUMBER(B1)=TRUE,TEXT(WEEKDAY(B1),"dddd"),"")

But it is redundant.

#### Joe4

It'll work for Vb code too?

like:
If Range("b1").Value = "ISNUMBER(B1)"
Actually, VBA has an ISDATE function that works even better, as it differentiates numbers from dates (presumably by how they are formatted).

So, in VBA, you can use:
Code:
`````` If IsDate(Range("B1")) Then
...``````

wow thanks!

Replies
20
Views
236
Replies
8
Views
71
Replies
1
Views
32
Replies
3
Views
41
Replies
5
Views
50