CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Dates In VB

  1. #1
    Join Date
    Aug 2001
    Posts
    2

    Dates In VB

    Hello
    I have a problem with dates in vb;
    I have an application that querries and updates dates fields in an Access DataBase. I work with Windows in french. When I send an update request on a date field, the day and the month are sometimes swapped. Any Idea?

    Regards


  2. #2
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: Dates In VB

    Didn't u try the format command ?
    Did u use different machines in which Date formats r different?
    Check for the above and do some chanes necessary & see.
    Good Luck
    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  3. #3
    Join Date
    Jul 2000
    Location
    india
    Posts
    49

    Re: Dates In VB

    If you are using SQL statement like "Update SomeTable where Datefield=datevalue' always specify datevalue in mm/dd/yyyy format (Access and MS Sql Server) .
    For Ex: "update mytable set dtfield='" & format(date,"mm/dd/yyyy") & "' where dtfield='" & format(somedate,"mm/dd/yyyy") & "'"

    If you are using Recordset.Update method use default VB date format (which is also system's date format)

    hope this works


  4. #4
    Join Date
    Aug 2001
    Posts
    2

    Re: Dates In VB

    I've found a solution!!!
    When I was using the following syntax, the used Date Format was the International One (mm/dd/yy);

    "UPDATE t_Dates set Date_Field = date WHERE Date_Field = AnotherDate"



    So, with the following code, the Date Format is the System's one (european in my case);

    Qdf = Database.CreateQueryDef ("", "UPDATE t_Dates set Date_Field = date WHERE Date_Field = AnotherDate")
    Qdf.Execute




    That's It, Thanx.


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

Featured