Bonjour,
j'ai une erreur concernant timestamp : Nom : erreur timestamp.JPG
Affichages : 221
Taille : 18,6 Ko
j'ai une macro qui va chercher un calendrier,Nom : calendrier.JPG
Affichages : 290
Taille : 39,0 Ko
elle fait une requete SQL avec juste un select et la macro est interrompu par le message : impossible de convertir 'ma date selectionnée du calendrier' en timestamp sachant que le format date de ma BDD est exemple : 2008/03/13 07:20:18 458.

je ne sais pas convertir ce format dans ma text box et ou dois-je l'incrémenter dans ma macro pour que les 2 dates correspondre.
en espérant que j'ai compris cette erreur d'exécution Timestamp

requete excel vba :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Public CoUnT As Integer
 
Private Sub Cal1_Click()
 
If CoUnT = 1 Then
   txt_start.Value = Cal1.Value
    CoUnT = 2
Else
    txt_end.Value = Cal1.Value
    CoUnT = 1
End If
 
End Sub
 
Private Sub UserForm_Initialize()
 
CoUnT = 1
Cal1.Month = Month(Now)
End Sub
 
Private Sub cmd_ok_Click()
 
Dim db_obiasa9 As New ADODB.Connection
Dim rs_obiasa9 As New ADODB.Recordset
Dim SQL As String
Dim myvar
 
Dim datedebut As Date
Dim datefin As Date
 
datedebut = Format(txt_start.Value, "DD/MM/YYYY")
datedebut = Format(txt_end.Value, "DD/MM/YYYY")
 
If txt_start.Value = "" Then myvar = MsgBox("Il faut remplir au moins 'Date de Debut'", vbCritical, "Attention!!!")
 
Application.ScreenUpdating = False
 
Workbooks.Add
 
    SQL = "SELECT a.no_int_ord_fab, a.cd_moy, a.cdevt, a.qte, a.dur_evt, a.cd_perso_resp, dateformat(a.dte_hre_mvt,'DD/MM/YYYY'), a.cd_cau, a.cd_def, a.cout_section, a.mnt_sect "
    SQL = SQL & "FROM obi.evtate a, obi.ordfab b "
    SQL = SQL & "WHERE a.no_ste = b.no_ste "
    SQL = SQL & "AND a.no_int_ord_fab = b.no_int_ord_fab "
    SQL = SQL & "AND b.no_ste='01' "
    SQL = SQL & "AND b.cd_af='RELANCE' "
 
    If txt_end.Text = "" Then
    SQL = SQL & "AND a.dte_hre_mvt = '" & txt_start.Value & "' "
Else
 
    SQL = SQL & "AND a.dte_hre_mvt BETWEEN TO_DATE('" & txt_start.Value & "','DD/MM/YYYY') AND TO_DATE('" & txt_end.Value & "','DD/MM/YYYY') "
 
    MsgBox SQL
End If
 
    SQL = SQL & "ORDER BY a.no_int_ord_fab"
 
    Debug.Print SQL
 
    db_obiasa9.ConnectionString = "DSN=obiasa9;UID=admin;PWD=admin"
    db_obiasa9.Open
    rs_obiasa9.Open SQL, db_obiasa9
 
    Range("B3").CopyFromRecordset rs_obiasa9
 
    rs_obiasa9.Close
    db_obiasa9.Close
j'essai avec 'TO DATE' pour la conversion de mes dates selectionnées dans mon calendrier mais le message 'TIMESTAMP' apparait toujours.

J'ai été sur le forum excel vba, mais malgrés les réponses je n'ai pu corriger cette erreur



Si vous avez une idée, elle sera la bienvenue ,
car je bloque

Merci d'avance a tous
@+