G
Guest
I am trying to get a UK format date of dd/mm/yyyy.
Why does the following subroutine not return a valid date in a web form?
The date returned is #12:00:00 AM# but the date I entered into the text box
was 24/06/2006.
The other solution I have tried is given by the following two lines that do
not compile because a value of date type cannot be converted to datetime:
Dim assessmentDate As String = "24/06/2006"
Dim dt As dateTime = System.DateTime.ParseExact(assessmentDate,
"dd/MM/yyyy", Nothing)
Private Sub getDate2()
Dim assessmentDate As Date
Dim MyCulture As New System.Globalization.CultureInfo("en-GB")
Try
assessmentDate =
System.DateTime.Parse(txtAssessmentDate.Text.Trim, MyCulture)
Catch ex As Exception
lblValidAssessmentDate.Text = "Assessment date: not a valid date
in UK format"
End Try
End Sub
The date is retrieved from my calendar control into the text box ok as
dd/mm/yyyy. Then I want to take it from the textbox and convert it into a
datetime so that I can store it in a SQL server datetime column. Here is the
parameter being passed into the VB function that calls the store procedure:
ByVal assessmentDate As System.DateTime,
Here is the SQL parameter:
command.Parameters.Add("@assessmentDate", SqlDbType.DateTime, 11)
command.Parameters("@assessmentDate").Value = assessmentDate
Thank you anyone who helps.
Sincerely,
Richard.
Why does the following subroutine not return a valid date in a web form?
The date returned is #12:00:00 AM# but the date I entered into the text box
was 24/06/2006.
The other solution I have tried is given by the following two lines that do
not compile because a value of date type cannot be converted to datetime:
Dim assessmentDate As String = "24/06/2006"
Dim dt As dateTime = System.DateTime.ParseExact(assessmentDate,
"dd/MM/yyyy", Nothing)
Private Sub getDate2()
Dim assessmentDate As Date
Dim MyCulture As New System.Globalization.CultureInfo("en-GB")
Try
assessmentDate =
System.DateTime.Parse(txtAssessmentDate.Text.Trim, MyCulture)
Catch ex As Exception
lblValidAssessmentDate.Text = "Assessment date: not a valid date
in UK format"
End Try
End Sub
The date is retrieved from my calendar control into the text box ok as
dd/mm/yyyy. Then I want to take it from the textbox and convert it into a
datetime so that I can store it in a SQL server datetime column. Here is the
parameter being passed into the VB function that calls the store procedure:
ByVal assessmentDate As System.DateTime,
Here is the SQL parameter:
command.Parameters.Add("@assessmentDate", SqlDbType.DateTime, 11)
command.Parameters("@assessmentDate").Value = assessmentDate
Thank you anyone who helps.
Sincerely,
Richard.