Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

SQL date storage/conversion issue and Access 2010/VBA

$
0
0

I'm running an Access 2010 front end with SQL 2012 Express.

When I generate a date in Access using "Date()" or "Now" and store it, it works fine and is in the correct format "dd/mm/yyyy".

However, when I store a typed in date (format of "dd/mm/yyyy") it throws an error (3146 ODBC - call failed).

As a work around I've converted the date, using a custom function (below), to "yyyy-mm-dd" and that works, but isn't what I want.

Public Function fnDateToSQL(dtDate As Date) As String
    Dim strdate As String
    
    If Len(dtDate) > 0 Then
        strDate = Year(dtDate) & "-" & Month(dtDate) & "-" & Day(dtDate)
    Else
        strdate = ""
    End If
    
    fnDateToSQL = strdate
    Exit Function
End Function

I can't find anything to point me in the direction to understand:-

1. What I need to change so that it works in the format of "dd/mm/yyyy"

2. What I need to do to convert all the current stored dates to the correct format

Thanks,

Chris.


_________________________________________________________ Every day is a school day!


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>