Hi everyone,
This has been driving me batty for the last while. I have an application that is passing up data to a SQL server table. Part of the data is dates. Because of settings on the SQL server the update will not accept the MM/dd/yyyy format. I have been trying for quite some time to get around this.
For some more information. Changing the update method or the server regional settings is not an option and I don't want to change my regional settings as this may not reflect the production server when this goes live.
Here is what I have tried so far
I hae also tried:Code:Dim dateEnd As Date = Date.MinValue Dim dateStart As Date = Date.MinValue If IsDate(Me.txtPostEnd.Text) Then dateEnd = CType(Me.txtPostEnd.Text, Date) dateEnd = dateEnd.ToString("dd/MM/yyyy") dbJobAppData.EndDate = dateEnd.ToShortDateString End If
When run I receive error that conversion of string '28/02/2011' to type Date is not valid.Code:If IsDate(Me.txtPostEnd.Text) Then dateEnd = CType(Me.txtPostEnd.Text, Date) dbJobAppData.EndDate = CDate(dateEnd.ToString("dd/MM/yyyy")) End If
It works fine if the day is 12 or below because it still thinks that is the month. Is there a way to force the code to recogize that I want to use dd/MM/yyyy format or even dd/MMM/yyyy format?
This has to be done at thhe vb code side as the update to the SQL server is completed via a custom framework so I can't customize the SQL code to insert the data using a CONVERT
Thanks for any suggestions.




Reply With Quote