How to test for the absence of a date

When I install my application I set an installation date and store it in the registry.  But first I have to check that it's not already there.  Unfortunately the isdate() function returns True for a  date of 12:00:00: AM

Is there a way to test if an 'empty' date is greater than, say, 01/01/2000?

Thanks in advance,

Clive
Clive BeatonAccess DeveloperAsked:
Who is Participating?
 
Dale FyeCommented:
Dates are actually stored in your database as double precision numbers, with the integer portion representing the date and the decimal portion representing the % of the day which has passed.  If Install date is showing up as 00:00:00 or 12:00:00 AM then that represents a value of zero (0).  The following should meet your needs.

IF INT(InstallDate) = 0 then
    'no value
Else
   'has been set
end if
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
How can it be Empty yet have a value ?
And this Date is in the Registry ?
0
 
Ryan ChongCommented:
Is there a way to test if an 'empty' date is greater than, say, 01/01/2000?
it depends on how you get and validate your date value.

dim yourVar as date
yourVar = <how you get the value??>

Open in new window


then try like:

if yourVar >#01/01/2000# then
    'Greater than 01/01/2000
else
    'Less or equal to 01/01/2000
end if

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Gustav BrockCIOCommented:
The  date of 12:00:00: AM is really 1899-12-30 00:00:00 because the numerical value of that is 0 (zero). Thus, it makes sense, that this value is the initial value of the registry entry.

Using this info, the test could be:

If InstallDate = #12:00:00 AM# Then
    ' Registration date has never been set.
Else
    ' InstallDate holds the last registered date.
End If

Open in new window

0
 
Clive BeatonAccess DeveloperAuthor Commented:
Sorry, I was using the term 'Empty' as a generalization.  I guess I could have asked the question better.  What I Want to do is:

Set a registry entry with a date.
Get the registry entry and return a date.
Detect if the registry entry did not contain a date.

CRB
0
 
Gustav BrockCIOCommented:
Set and get, you wrote, you have running.
All that was missing was the check for not containing (= never been set) a date. That was provided.
0
 
Clive BeatonAccess DeveloperAuthor Commented:
On some client machines, I get  0:00:00 , not 12:00:00 AM
0
 
Clive BeatonAccess DeveloperAuthor Commented:
Is there a way of checking if a registry entry actually exists?
0
 
Gustav BrockCIOCommented:
That's just a different format. The value is the same.
0
 
Gustav BrockCIOCommented:
Is there a way of checking if a registry entry actually exists?

Either try to read it and catch an error. If no error, it exists.
Or read the key and enumerate the entries. If your entry is not listed, it does not exist.
0
 
Clive BeatonAccess DeveloperAuthor Commented:
How do I read the key and enumerate the entries?
0
 
Gustav BrockCIOCommented:
An example can be found here:

How to read a registry key and its values

It is VBScript which easily can be transferred to VBA.
0
 
Clive BeatonAccess DeveloperAuthor Commented:
Thank you both very much.

CRB
0
 
Dale FyeCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.