Display Time Portion of Date

  • Thread starter Thread starter ZRexRider
  • Start date Start date
Z

ZRexRider

Hi,

I have a date/time field in my SQL database. I want to display only
the time portion HH:MM. I had this working by doing the following:

If IsNull(objDateField.Value) Or objDateField.Value = "" Then
objTimeField.Value = ""
Else
objTimeField.Value = Format(objDateField, "hh:nn")
End If

This worked just fine until I realized that the above action makes
me.dirty=true and I lose the ability to detect True user edits to the
form when closing.

I would like to simply format the display of this value so that it
shows only the time portion.

My input mask for these time fields is: 00:00;0;_

However without my code above this field displays "11/12/2005 1:23:00
AM" even with this mask.

Is there a way to display this date as "01:23" without changing the
value (like my code is doing above)?
Thanks
 
The Input Mask property affects entry, but the Format property affects
display. Try setting the text box's Format property to:
Short Time

Alternatively, if you just want to display the time, you could use a text
box bound to:
=TimeValue([MyDateField])

(BTW, attempting to set a date/time field to a zero-length string would not
work anyway. You are not setting the value now, but it would be Null rather
than "" if you did need to.)
 
Back
Top