Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 791
  • Last Modified:

ODBC Date Format

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
Cuervo
Asked:
Cuervo
  • 4
  • 2
1 Solution
 
Anthony PerkinsCommented:
Post your code and tell us what database your are using.

Anthony
0
 
CuervoAuthor Commented:
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
 
Anthony PerkinsCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Anthony PerkinsCommented:
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
 
CuervoAuthor Commented:
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
 
Anthony PerkinsCommented:
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
 
DanRollinsCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now