I have a technical Date problem that's really difficult for me, I have a "custom made" Date format MM.DD.YY this is actually extracted from SAP and theirs no other format option offered such as ShortDate, LongDate etc. so now I making a sql query that must convert SAP date to a date Format that is recognizable to MS Access and I choose the ShortDate MM/DD/YY using ADO. I read about the Format() command using ADO online and experiment on it and hoping I get something right.
This one's causes a big error that's beyond my understanding and I was wondering if anyone could help me with it and a little explanation would be nice. It is very important that I solve this, so…pls…pls help ME!
Thanks in advance!
Code:
Public Sub ConvertDate()
Code:
[i]Dim cnn1 As ADODB.Connection[/i]
[i]Dim rst1 As ADODB.Recordset[/i]
[i]Dim sql As String[/i]
[i]Dim mm As Variant[/i]
[i]Dim dd As Variant[/i]
[i]Dim yy As Variant[/i]
[i]Set cnn1 = New ADODB.Connection[/i]
[i]cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _[/i]
[i]"Data Source=" & CurrentProject.Path & _[/i]
[i]"\nope.mdb"[/i]
[i]Set rst1 = New ADODB.Recordset[/i]
[i]rst1.Open "Sheet1", cnn1, adOpenDynamic, adLockPessimistic, adCmdTable[/i]
[i]sql = "SELECT * FROM Sheet1" & Format(rst1.Fields("MyDate").Value, "mm/dd/yy")[/i]
[i]cnn1.Execute sql[/i]
[i]Debug.Print rst1.Fields("Mydate").Value[/i]
[i]End Sub[/i]
This one's causes a big error that's beyond my understanding and I was wondering if anyone could help me with it and a little explanation would be nice. It is very important that I solve this, so…pls…pls help ME!
Thanks in advance!
Comment