Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL Server date issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Server date issue

 Post Reply Post Reply
Author
joshb View Drop Down
Groupie
Groupie


Joined: 26 June 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote joshb Quote  Post ReplyReply Direct Link To This Post Topic: SQL Server date issue
    Posted: 30 May 2003 at 10:09am

I am sure this type of question has been asked before but I searched and could not find it. I am migrating from MS Access to MSServer. Here goes:

I have a table holding company policy document info from 2002 and 2003. Well on one of my pages I have a count of how many documents for each year there are, here is my MS Access query:

strSQL = "SELECT Count(tblBulletins.Access_ID) as Bulletins_2002_Count FROM tblBulletins WHERE Approved = True And Deleted = False AND tblBulletins.DateIssued BETWEEN #1/1/2002# AND #12/31/2002#"

Well when I tried making a Stored Proc out of it changing the True to 1 and False to 0 everything is fine until I get to the date surrounded by #'s.

How can I select a date range in SQL I guess is my question, I tried just putting '1/1/2002' AND '12'31'2002' but no dice. It returned incorrect counts.

Can someone please help.

Joshua

 

I'm a wannabe programmer that knows how to do nothing but create invalid procedure arguments.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2003 at 10:52am
Using:
strSQL = "SELECT Count(tblBulletins.Access_ID) as Bulletins_2002_Count FROM tblBulletins WHERE Approved = 1 And Deleted = 0 AND tblBulletins.DateIssued BETWEEN '1/1/2002' AND '12/31/2002'
is correct syntax thus I suggest doing a count(*).
If that returns an incorrect number I guess your data itself has a problem.
Back to Top
joshb View Drop Down
Groupie
Groupie


Joined: 26 June 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote joshb Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2003 at 11:48am

Thanks a bunch, it works now.

I'm a wannabe programmer that knows how to do nothing but create invalid procedure arguments.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.