|
-
Jul 2nd, 2002, 01:29 AM
#1
I really need help
I’m trying to record date in access DB, but I’ve the following problem:
First at all, my regional setting is formated “dd-mm-yyyy” and I can’t change it
Well, if I enter date with day less 12, the program record date on format “mm-dd-yyyy”, but if I enter date with day more 12, the program record date on format “dd-mm-yyyy”, for example:
Enter date 3-6-2002 result 6-3-2002
Enter date 13-6-2002 result 13-6-2002
What is happening and how can I fix it.
I attach a sample
-
Jul 2nd, 2002, 01:31 AM
#2
I haven't downloaded the ZIP, but are you using the format() function to format your dates?
-
Jul 2nd, 2002, 01:36 AM
#3
use formatdatetime() function
-
Jul 2nd, 2002, 01:38 AM
#4
Can you try to downloaded the ZIP again...please
-
Jul 2nd, 2002, 01:43 AM
#5
Frenzied Member
Do it this way:
VB Code:
Private Sub Command1_Click()
Set db = OpenDatabase(App.Path & "\fecha.mdb")
SQLGrabar = "INSERT INTO prueba (Inicio,fin) VALUES (" & gSQLDate(DTPicker1) & "," & gSQLDate(DTPicker2) & ")"
db.Execute SQLGrabar
Set rs = db.OpenRecordset("SELECT * FROM [prueba]")
rs.MoveLast
Label1 = rs!inicio
Label2 = rs!fin
End Sub
Public Function gSQLDate(x As Date) As String
If IsNull(x) Then
gSQLDate = "NULL"
Else
gSQLDate = "#" & Month(x) & "/" & Day(x) & "/" & Year(x) & "#"
End If
End Function
oh1mie/Vic

-
Jul 2nd, 2002, 01:46 AM
#6
I try using format function, but it's the same
-
Jul 2nd, 2002, 01:47 AM
#7
try out this
Code:
SQLGrabar = "INSERT INTO prueba(Inicio,fin) VALUES (#" & DTPicker1 & "#, #" & DTPicker2 & "#)"
'change it to...
SQLGrabar = "INSERT INTO prueba(Inicio,fin) VALUES (#" & FormatDateTime(DTPicker1, vbShortDate) & "#, #" & FormatDateTime(DTPicker1, vbShortDate) & "#)"
-
Jul 2nd, 2002, 01:49 AM
#8
or this way
VB Code:
SQLGrabar = "INSERT INTO prueba(Inicio,fin) VALUES (#" & format(DTPicker1,"dd/mm/yyyy") & "#, #" & format(DTPicker2,"dd/mm/yyyy") & "#)"
-
Jul 2nd, 2002, 02:00 AM
#9
Thank oh1mie/Vic
that work properly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|