CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Posts
    25

    date format changed with SQL

    I am new in VB. My database(in Ms-Access) is containg a field "CURRENTDATE", I written a following routine to update CURRENTDATE :-
    DIM CN AS NEW ADODB.CONNECTION
    DIM CnStr AS STRING
    CNSTR="PROVIDER................."
    CN.OPEN CNSTR
    RS.EXECUTE "UPDATE <TABLE NAME> SET CURRENTDATE = #" & NextDate & "#"
    offcourse SQL updates records but in mm/dd/yyyy format while NextDate variable is well in dd/mm/yyyy format. My regional setting is dd/mm/yyyy.

    VB Experts please tell me why is it so ?


  2. #2
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090

    Re: date format changed with SQL

    try:
    RS.EXECUTE "UPDATE <TABLE NAME> SET CURRENTDATE = format(NextDate,"dd/mm/yyyy")


  3. #3
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    56

    Re: date format changed with SQL

    First thing you got to check is the regional settings on the SQL Server, I going to assume that it is US. if so try settting NextDate as a string value or use one of these functions:


    NextDate = Format(MyDate, "dd/mm/yyyy")




    Andy

    Don't forget to rate!!!

    Andrew Lennon (Berlitz)
    Automation Dev Engineer

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