Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ODBC Date Format

Posted on 2002-05-28
7
Medium Priority
?
785 Views
Last Modified: 2008-03-10
Hi, i usually use the ODBC date format, so my applications do not depend of the machine's regional configuration, like this:

{ ts '2002-02-02 00:00:00 ' }

This intends for { ts 'yyyy-mm-dd hh:mm:ss' }

This does work well when the query is armed inside an string variable and then thrown in the Execute method, but now i have to use parametrized queries, using the "?" sign and the Parameters collection. Too bad, i cannot make that the parameters collection accept the date values with the ODBC date format, i have to do it with the standard date format mm-dd-yyyy which does my application regional configuration dependent.

Is there a workaround for this???

Thanks
0
Comment
Question by:Cuervo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7040643
Post your code and tell us what database your are using.

Anthony
0
 

Author Comment

by:Cuervo
ID: 7042631
SQL Server 7.0

Here is the code:


Private Sub collectParams(ByRef cmd As ADODB.Command, ByVal argparams As Variant)

Dim params As Variant, v As Variant
Dim iLength As Long
Dim i As Integer, l As Integer, u As Integer

If Not IsArray(argparams) Then Exit Sub
   
params = argparams
For i = LBound(params) To UBound(params)
    l = LBound(params(i))
    u = UBound(params(i))
    'Chequear por nulls
    If u - l = 3 Then
        If VarType(params(i)(3)) = vbString Then
            v = IIf(params(i)(3) = "", Null, params(i)(3))
        Else
            v = params(i)(3)
        End If
        'Chequear si el tamaño es 0
        If params(i)(2) <= 0 Then
            iLength = 1
        Else
            iLength = params(i)(2)
        End If
        cmd.Parameters.Append cmd.CreateParameter(params(i)(0), params(i)(1), adParamInput, iLength, v)
    Else
        RaiseError M_MODNAME, "collectParams(...): incorrect # of parameters", bWriteToLog:=True
    End If
Next i

End Sub

The code fails in the "cmd.Parameters.Append cmd.CreateParameter(params(i)(0), params(i)(1), adParamInput, iLength, v)" statement, because it doesn't accept the v value "{ ts '2002-01-01 00:03:00' }" with the params(i)(1)=adDBTimeStamp data type.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7042841
Just a quick response, before I look at it in more depth, the data type should be adDate not adDBTimeStamp

I realize this may have nothing to do with the subject, but are these parameters used in a Stored Procedure and if so can you post the Stored Procedure?

Anthony
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7043442
Also, please maintain this open question:

Hard disk drive knock out Date: 04/19/2002 10:55AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=hardgen&qid=20291520
Linux Proxy and Windows Client Date: 08/29/2001 09:55AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=linuxnet&qid=20175797

Thanks,
Anthony
0
 

Author Comment

by:Cuervo
ID: 7045576
Hi. Thanks for the answer. The store procedure is nothing really special, in fact, the code in here are not even feeling the store procedure. The value just doesn't get to it in this instances.

The store procedure that is using this function receives a paremeter that is a datetime.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 400 total points
ID: 7045710
First of all I was wrong adDBTimeStamp is the correct type.

Second I should clarify that I do not use the ODBC driver (for performance reasons I use the SQL Server native driver).  However you may want to check out the following articles from MSDN:
FIX: Syntax Error When You Use ODBC Canonical Date Format as Parameter to SQL Stored Procedure (Q270586)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q270586&SD=MSKB&
FIX: Engine Does Not Handle Intl Dates in Localized Version (Q223318)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q223318&SD=MSKB&

Suerte,
Anthony
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851216
Hi Cuervo,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept acperkins@devx's comment(s) as an answer.

Cuervo, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question