Results 1 to 9 of 9

Thread: I really need help

  1. #1
    fdelpuerto
    Guest

    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

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I haven't downloaded the ZIP, but are you using the format() function to format your dates?

  3. #3
    khalik
    Guest
    use formatdatetime() function

  4. #4
    fdelpuerto
    Guest
    Can you try to downloaded the ZIP again...please

  5. #5
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043
    Do it this way:
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Set db = OpenDatabase(App.Path & "\fecha.mdb")
    4.    
    5.     SQLGrabar = "INSERT INTO prueba (Inicio,fin) VALUES (" & gSQLDate(DTPicker1) & "," & gSQLDate(DTPicker2) & ")"
    6.     db.Execute SQLGrabar
    7.    
    8.     Set rs = db.OpenRecordset("SELECT * FROM [prueba]")
    9.    
    10.     rs.MoveLast
    11.     Label1 = rs!inicio
    12.     Label2 = rs!fin
    13.    
    14.    
    15. End Sub
    16. Public Function gSQLDate(x As Date) As String
    17.     If IsNull(x) Then
    18.        gSQLDate = "NULL"
    19.     Else
    20.        gSQLDate = "#" & Month(x) & "/" & Day(x) & "/" & Year(x) & "#"
    21.     End If
    22. End Function
    oh1mie/Vic


  6. #6
    fdelpuerto
    Guest
    I try using format function, but it's the same

  7. #7
    khalik
    Guest
    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) & "#)"

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    or this way

    VB Code:
    1. SQLGrabar = "INSERT INTO prueba(Inicio,fin) VALUES (#" & format(DTPicker1,"dd/mm/yyyy") & "#, #" & format(DTPicker2,"dd/mm/yyyy") & "#)"

  9. #9
    fdelpuerto
    Guest
    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
  •  



Click Here to Expand Forum to Full Width