VB6 and ms SQL 2005 DATETIME

G

Guest

Morning,
Could'nt find a post / site that has addressed this issue and I
would be very surprised if I'm the first to find this.

I am currently having an issue passing a parameter via a stored procedure in
vb6 to SQL 2005 that is requiring a datetime format.

VB6 supports these separatly i.e. DATE, TIME were as VB.Net etc. support
this as DATETIME.

Is there any way I can get the date into the SQL 2005 database, not fused
about the time part as this would help being stored as 00:00:00.

What I've tried so far is:

strDate = Format(strDate, "yyyy-mm-dd 00:00:00")

but when passing through it details parameter not supported:

..Parameters.Append .CreateParameter("dteDate", adDate, adParamInput, ,
dteDate)

Any idea's?

Many thanks,

Dan
 
K

Ken Halter

In Loving Memory - http://www.vbsight.com/Remembrance.htm
dan688 said:
Morning,
Could'nt find a post / site that has addressed this issue and I
would be very surprised if I'm the first to find this.

I am currently having an issue passing a parameter via a stored procedure
in
vb6 to SQL 2005 that is requiring a datetime format.

VB6 supports these separatly i.e. DATE, TIME were as VB.Net etc. support
this as DATETIME.

Is there any way I can get the date into the SQL 2005 database, not fused
about the time part as this would help being stored as 00:00:00.

What I've tried so far is:

strDate = Format(strDate, "yyyy-mm-dd 00:00:00")

but when passing through it details parameter not supported:

.Parameters.Append .CreateParameter("dteDate", adDate, adParamInput, ,
dteDate)

Any idea's?

Many thanks,

Dan

When you use the Format$ function, you're converting the value to a string,
no matter what.

VB6 has separate Date/Time functions but that has nothing to do with the
Date data type. They're simply functions that extract either the Date or the
Time from a Date datatype. There's no way to store only a time or date in
the Date datatype.

Dim WhatEver As Date
WhatEver = Now ' This is the current date/time and is a true Date datatype.
that any database should accept.

WhatEver = #2006/08/07# is also a true Date data type.
WhatEver = "2006/08/07" is not. It's a string.
 
G

Guest

Do you have any idea what I would pass the parameter type through as because
adDate is not valid!
 
K

Ken Halter

dan688 said:
Do you have any idea what I would pass the parameter type through as
because
adDate is not valid!

'======
Private Sub Command1_Click()
Dim dt As Date

dt = Now
dt = CDate(Format$(dt, "yyyy-mm-dd"))

Debug.Print dt '<-- pass dt. this should contain only the date

End Sub
'======
 
C

Cor Ligthert [MVP]

Dan,

I don't know if you are an (USA) American, than you can use DateTime
literals, try to avoid outside that world those and just use the New
datetime which is conform ISO.

Unlucky enough does the VB debugger (not the C# debugger) only represents
datetimes in USA American notation, while the internal format has nothing to
do with that.

Beside that is the *DateTime* in the Microsoft Access and Jet Servers not a
string but a value representing ticks in 1000/3 seconds. Therefore you never
can say that a date or a time is alone stored.

I hope this gives an idea

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top