Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find if a data variable contains a time 1

Status
Not open for further replies.

AdamVBWylde

Programmer
Jun 7, 2001
8
0
0
GB
Does anybody know how to work out if a date variable contains a time please?

Eg. If you are debugging and hover over a date variable it either shows '1/1/2001' or '1/1/2001 10:59' - but how do I test for the existance of the 10:59 portion.

Thanks

PS - It is not good enough for me to test for a time of 00:00 as this could be still be a real time!
 
One way...



If DateValue(dtAnyDate) = dtAnyDate Then
is just date
else
is date and time
end if
 
Dim lPosition as long
dim dDate as date
Dim sTime as string

lPosition = InStr(dDate, ":")
sTime = Mid$(ddate, lTest - 2)

Its not the cleanest, but it works
 
Yeah - I'd thought of the Instr method, but need to support other languages where : may not be the separator.

DateValue works perfectly. Thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top