Solved

ODBC Date Format

Posted on 2002-05-28
7
779 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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 100 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 22 hours left to enroll

635 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