metropia
asked on
format datetime to use year with two digits only
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Applied when? When the data is posted to the server, or as the user is typing?
ASKER
when the data is posted to the server?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
one of the events on the for, is from a preview button, after date is entered and button gets clicked, this function happens:
Is it possible to format the date right here, or before?
Protected Sub cvDateMfg_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvDateMfg.ServerValidate
If Date_IsValid(Me.txtDateMfg.Text) Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
Is it possible to format the date right here, or before?
ASKER
i got that one wrong, the first code that gets executed is:
Then this code:
where would it be the right spot to specify the format? Thank you for your help.
I am sorry for the many posts, I am getting frustrated a bit.
Protected Sub cvDateMfg_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvDateMfg.ServerValidate
If Date_IsValid(Me.txtDateMfg.Text) Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
Then this code:
Protected Sub cvDateMfg_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvDateMfg.ServerValidate
If Date_IsValid(Me.txtDateMfg.Text) Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
where would it be the right spot to specify the format? Thank you for your help.
I am sorry for the many posts, I am getting frustrated a bit.
ASKER
this is how I ended up doing it:
Can you please let me know if you see anything wrong, or code that is not needed?
Thank you.
Protected Sub cvDateMfg_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles cvDateMfg.ServerValidate
Dim dtDateMfg As DateTime = Nothing
If DateTime.TryParse(Me.txtDateMfg.Text, dtDateMfg) Then
Me.txtDateMfg.Text = dtDateMfg.ToString("MM/dd/yy")
End If
If Date_IsValid(Me.txtDateMfg.Text) Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
Can you please let me know if you see anything wrong, or code that is not needed?
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how can the format be applied?
my textbox is: Me.txtDateMfg.Text