Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2003, 05:16 PM
Authorized User
 
Join Date: Jun 2003
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Dates From VB6 to SQL7


   Hey guyz i got a problem with dates in my project. I would like to get the date from my client program en pass it to the stored procedure in my database.

   First i had to concatenate the date(example below) so as to be able to compare the dates when passed to the Stored procedure en also am in Australia where we use 01/05/2003 as our date format i had to change (concatenate) to 2003-05-01.

Public gFromDate,gToDate As String

Dim fDate As Date
Dim tDate As Date

    fDate = Me.dtpFrom.Value
    'concatenate the date string to be used SQL 7
    gFromDate = Mid(fDate, 7, 10) + "-" + Mid(fDate, 4, 2) + "-" + Mid(fDate, 1, 2)
    tDate = Me.dtpTo.Value
    'MsgBox (wDate)
    gToDate = Mid(tDate, 7, 10) + "-" + Mid(tDate, 4, 2) + "-" + Mid(tDate, 1, 2)
    MsgBox (" gToDate -> " & gToDate & " gFromDate -> " & gFromDate)

    Set objRst = Nothing

    objRst.Open "Get_OrderRecords_By_Criteria(gFromDate,gToDat e)" _
        , objConn, adOpenDynamic, adLockReadOnly, adCmdStoredProc

    Set Me.HFPhones.DataSource = objRst
 Problem: if i declare gToDate and gFromDate As Date even after changing them it still remains the same format i.e 01/05/2003.

 I also changed the variable types that am passing in the Stored procedure to Char from smalldatetime but still i get syntax error ( "converting character string to smalldate data type") when comparing the dates (an example of the stored procedure below)

CREATE PROCEDURE Get_OrderRecords_By_Criteria (
@fromDate char(10),
@toDate char(10)) AS

Select fldDate As RecDate,fldName As Customer
FROM tblOrderRecords
Where fldDate > @fromDate AND fldDate < @toDate
GO
My problem is how would i go about having the wright date passed to the Stored Proc from my Client Code.?? please help!!!

LION OF JUDDAH!
__________________
LION OF JUDDAH!
 
Old June 23rd, 2003, 08:16 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my experience with database's accessed by JET's engine, all dates end up in the mm/dd/yyyy format. you can pass it a string that says "jan 1, 01" and it will come back 01/01/2001. I think you will need to convert it to your format when it comes BACK from the database if you dont' want the user seeing JET's converted date. Hope this helps you =o)
 
Old June 23rd, 2003, 10:12 PM
Authorized User
 
Join Date: Jun 2003
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey thanks... but whatever i try it comes back with an error. What am sure of is even though in your table rows SQL 7 will show you 01/12/2003 date format.. if you wanna compare the dates you will have to use 2003-05-01 format. even a result set will be retutrned with 2003-05-01 format. Try it if you have got SQL7..

Any more Ideas

LION OF JUDDAH!





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem getting the last 4 dates smiter SQL Language 3 January 16th, 2007 05:19 AM
Upgrade from SQL7 to SQL2000 - Problem with an SP paulymac SQL Server 2000 2 December 10th, 2004 05:20 AM
SQL7-SQL2K collation problems dhulse SQL Server 2000 2 July 6th, 2004 03:47 PM
Problem with dates in VB6 to SQL7 chiefouko Pro VB Databases 1 June 26th, 2003 05:11 PM
How 2 query tables from 2 different SQL7 databases mcp SQL Server ASP 3 June 5th, 2003 08:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.