Dates, VB6 and SQL Server 7.0 
Author Message
 Dates, VB6 and SQL Server 7.0

Hi,

I'm trying to return some records from an SQL Server 7 Database using date
restrictions but receive a message saying that there is an error near the #.
Several books say that you must use pound (#) signs when using Date
Restrictions.

I've enclosed the code that I am using and was wondering if someone can
point me in the right direction as to why this won't work. I've formatted
the date in American Format (I'm in Australia) but I still have no joy.

-------------Code Start
Set gds = gcnSg.OpenResultset("SELECT Despatched, DateReceived, InventoryID
FROM tblInventory WHERE Despatched = 0 AND tblInventory.DateReceived < #" &
Format$(Now, "mm/dd/yyyy") & "#", rdOpenStatic)
-------------Code End

The other problem I have is that when I do an SQL Execute Statement for
example ("UPDATE tblFax SET DateFaxed = " & Format$(Now, "Short Date")
the date inserts in mm/dd/yyy format, even if I try and format it myself. I
have told the ODBC driver to use Regional Settings as well. The only way I
can get the dates to work properly is by recursing through a recordset and
setting the date myself but this isn't very client/server friendly !

Any help would be greatly appreciated !

Regards,

David Webb
IT Manager
Super A-Mart Pty. Ltd.
Tel (07) 3343 9277
Fax (07) 3343 8566



Sat, 23 Feb 2002 03:00:00 GMT  
 Dates, VB6 and SQL Server 7.0
Hi David,

Usage of (#)-signs is specific to the JET used by Access. SQL-Server doesn't
recognize this.

You may use "... WHERE Date = MM/DD/YYYY" to update a date-field. IMHO, I
prefer using the convert-function:

"... WHERE Date = Convert(datetime,'dd.mm.yyyy',104)"

See T-SQL-help for more info.

Olaf



Quote:
> Hi,

> I'm trying to return some records from an SQL Server 7 Database using date
> restrictions but receive a message saying that there is an error near the
#.
> Several books say that you must use pound (#) signs when using Date
> Restrictions.

> I've enclosed the code that I am using and was wondering if someone can
> point me in the right direction as to why this won't work. I've formatted
> the date in American Format (I'm in Australia) but I still have no joy.

> -------------Code Start
> Set gds = gcnSg.OpenResultset("SELECT Despatched, DateReceived,
InventoryID
> FROM tblInventory WHERE Despatched = 0 AND tblInventory.DateReceived < #"
&
> Format$(Now, "mm/dd/yyyy") & "#", rdOpenStatic)
> -------------Code End

> The other problem I have is that when I do an SQL Execute Statement for
> example ("UPDATE tblFax SET DateFaxed = " & Format$(Now, "Short Date")
> the date inserts in mm/dd/yyy format, even if I try and format it myself.
I
> have told the ODBC driver to use Regional Settings as well. The only way I
> can get the dates to work properly is by recursing through a recordset and
> setting the date myself but this isn't very client/server friendly !

> Any help would be greatly appreciated !

> Regards,

> David Webb
> IT Manager
> Super A-Mart Pty. Ltd.
> Tel (07) 3343 9277
> Fax (07) 3343 8566



Sat, 23 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Insert date type varible through ODBC SQL server driver to SQL 7.0 database

2. Date problems in Access and SQL server 7.0

3. Date problems in Access and SQL server 7.0

4. SQL Server 7.0 date handling with Crystal

5. Problems inserting a date into SQL Server 7.0

6. Updating Dates in SQL-Server 7.0 Stored Proc thru VB.

7. Date problems in Access and SQL server 7.0

8. VB6.0 and SQL Server 7.0 OLAP Active X components -URGENT RESPONSE NEEDED

9. SQL Server 7.0 problem with VB6?

10. SQL Server 7.0/VB6 Problems with bit and checkboxes

11. using DTS to import a text file in SQL Server 7.0 with VB6

12. VB6.0 ODBC Error 3027 SQL Server 7.0

 

 
Powered by phpBB® Forum Software