I have the following Function in my application:
Public Function ToSqlDate(ByVal PassDate As Date) As Date
Return Date.Parse(PassDate.Month.ToString & "/" & PassDate.Day.ToString & "/" & PassDate.Year.ToString)
I call the function as follows:
SqlStart = ToSqlDate(StartDate) Where SqlStart has DataType "Date" and StartDate is a date value in a DateTimePicker Control.
When I run the application it abends with a message "String Was Not Recognised As Valid DateTime).
At this point in time when I hover the mouse over PassDate it displays a value of #9/30/2010# whereas I passed a value of 30/09/2010.
My Regional Setting for date is dd/MM/yyyyy.
The reason I must convert the Date to MM/dd/yyyy is that SQL requires it in this format in order to make comparisons with dates.
Any ideas or recommendations how I can get around this problem.