How to stop Date/Time field from showing TIME
Posted on 2004-11-19
I have an access database with a Date/Time field.
When I send the Date/Time field to my lblBirthDate it shows the date thats in the field....but then it shows "12:00:00 AM".
So I want to strip off the 12:00:00 AM part so I used the code below...the problem is that when the form loads the lblBirthDate is empty and my Constructor code is cant run with no date, so the form won't load. I tried "If lblBirthDate = "" Then exit sub Else run code" but then the form loads but my constructor code never runs.
How can I load a record after Form_Load, and fill in lblBirthDate, but not have the time.
'Add this code in the constructor of the form
public sub new
AddHandler label1.DataBindings("Text").Format, AddressOf DateToString
' Handles the Format event for the date
Protected Sub DateToString(ByVal sender As Object, ByVal e As ConvertEventArgs)
' You could use either of the following to convert to the proper date
'e.Value = CType(e.Value, DateTime).ToString("mm/dd/yyyy")
e.Value = CType(e.Value, DateTime).ToShortDateString