Advertisement

01.03.2005 at 07:59AM PST, ID: 21259930
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Date Select Query - select between two dates
Tags: between, date, query, select
i have a table with students details in it, i want to select all the students who joined a class on a particular day and then i need another query to select all students who joined classes over the course of date range eg 03/12/2003 to 12/12/2003.

i have tried with the following query, i need help putting my queries together
select * from tblstudents where classID='1' and studentstartdate between ('03/12/2004') and ('03/12/2004')

when i run this query i get this message

Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

the studentstartdate field is set as datetime 8 and the date looks like this in the table 03/12/2004  03:12:15

please help
Jas
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: JaspnBurke
Solution Provided By: Lowfatspread
Participating Experts: 10
Solution Grade: A
Views: 2115
Translate:
Loading Advertisement...
01.03.2005 at 08:08AM PST, ID: 12944395

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:10AM PST, ID: 12944417

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:18AM PST, ID: 12944493

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:20AM PST, ID: 12944522

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:24AM PST, ID: 12944546

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:29AM PST, ID: 12944591

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.03.2005 at 08:33AM PST, ID: 12944617

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.18.2005 at 02:44AM PST, ID: 13573113

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.18.2005 at 04:18AM PST, ID: 13573662

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.14.2005 at 10:10AM PDT, ID: 13783700

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.01.2005 at 07:01AM PDT, ID: 14121636

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.01.2005 at 07:50PM PDT, ID: 14127586

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.22.2005 at 04:21AM PDT, ID: 14274001

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.14.2005 at 06:32AM PDT, ID: 14880561

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
01.03.2005 at 08:08AM PST, ID: 12944395

Rank: Guru

try
select * from tblstudents where classID='1' and studentstartdate between convert(datetime, 12/03/2004')  and convert(datetime, '12/03/2004')
(ie mm dd yyy )
or
set dateformat dmy
select * from tblstudents where classID='1' and studentstartdate between convert(datetime, '03/12/2004') and convert(datetime,'03/12/2004')


 
01.03.2005 at 08:10AM PST, ID: 12944417
With the notation '03/12/2004' the SQL Server never knows what is the day value and what is the month value.

When you use '3 dec 2004' or '12 mar 2004' it works better.

I believe SQL Server uses the american notation. The format MM/DD/YYYY has to work also. But I always use the month format of above.

jan
feb
mar
apr
may
jun
jul
aug
sep
oct
nov
dec
 
01.03.2005 at 08:18AM PST, ID: 12944493

Rank: Guru

Don't use parenteses. And the format that SQL Server will accept is YYYY-MM-DD.
For return all records of a day you must set the finnish date to date+1, because SQL will take that as midnight (00:00):

select * from tblstudents where classID='1' and studentstartdate between '2004-12-03' and '2004-12-04'
 
01.03.2005 at 08:20AM PST, ID: 12944522

Rank: Genius

just use the YYYYMMDD format for your dtaes...

select * from tblstudents
 where classID='1'
 and studentstartdate between '20041203' and '20041212'

note did you want to include students whojoin of the 12 of december?

if you did then the enddate of the range needs to be the 13th Dec since time is also held...

   


Accepted Solution
 
01.03.2005 at 08:24AM PST, ID: 12944546
i have run these querys

KarinLoos
select * from tblrequests where datesent between convert(datetime, '12/03/2004')  and convert(datetime, '12/03/2004')
set dateformat dmy
select * from tblrequests where datesent between convert(datetime, '12/12/2004') and convert(datetime,'12/12/2004')
 
VMontalvao
select * from tblstudents where classID='1' and studentstartdate between '2004-12-03' and '2004-12-04'

i dont get any error messages but i also dont get any results back............

i need to get all the students who joined a class for the whole course of the day from midnight to midnight is this possible?
 
01.03.2005 at 08:29AM PST, ID: 12944591

Rank: Guru

(as per lowfats point--  datetime defaults to midnight if you dont add times, so change the start date to 1 day less effectively being midnight on day -1  till midnight on actual day..
set dateformat dmy
select * from tblrequests where datesent between convert(datetime, '11/12/2004') and convert(datetime,'12/12/2004')
Assisted Solution
 
01.03.2005 at 08:33AM PST, ID: 12944617
smashing i have results now.
 
03.18.2005 at 02:44AM PST, ID: 13573113
Hi all,
Can anyone help me to find a solution for this question
 
Parse for a numeric field using Active X in a DTS package?
 
I'm trying to parse for a numeric string from a column in a table. What I'm looking for is a numeric string of a fixed length of 8. The column is a comments field and can contain the numeric string in any position. I'm not familiar with ActiveX, so any suggestions will be useful. Thanks in advance,
Regards,
Jaishankar.
 
03.18.2005 at 04:18AM PST, ID: 13573662

Rank: Guru

Jaifhd, you need to start your own question. (see rules )
 
04.14.2005 at 10:10AM PDT, ID: 13783700
Hi,
I had the same problem . Try this and it will be ok
try
select * from tblstudents where classID='1' and studentstartdate >=datetime, 12/03/2003 and studentstartdate<'12/04/2004'
 (instad of between [start] and [end] I used >=[start] and <[end]+1)

:)
 
06.01.2005 at 07:01AM PDT, ID: 14121636
OK.  I'm closer, but still confused.  I added a sort criteria so I could see the latest record, and it's pulling records from yesterday (5/31/05).  I assumed with the -60 days part of the statement, I'd only get records at least 60 days old (the purpose of this view), so why is it pulling them through current?  Here's how it looks now.

SELECT     TOP 100 PERCENT *, [date] AS Expr1
FROM         dbo.bill
WHERE     (mat_code IN
                          (SELECT DISTINCT bill.mat_code
                            FROM          dbo.bill
                            WHERE      bill.date < DateADD(d, - 60, getDate())))
ORDER BY [date] DESC
 
06.01.2005 at 07:50PM PDT, ID: 14127586
SELECT     TOP 100 PERCENT *, [date] AS Expr1
FROM         dbo.bill
WHERE     (mat_code IN
                          (SELECT DISTINCT bill.mat_code
                            FROM          dbo.bill
                            WHERE      bill.date < DateADD(d, - 60, getDate())))
ORDER BY [date] DESC

this doesn't work because mat_code isn't distinct in the bill database.

So, it's limiting the data to all of the mat_codes that have a bill that has a date greater than 60 days old.

What you need is:
SELECT     TOP 100 PERCENT *, [date] AS Expr1
FROM         dbo.bill
WHERE    bill.date < DateADD(d, - 60, getDate())))
ORDER BY [date] DESC

 
06.22.2005 at 04:21AM PDT, ID: 14274001

if your date format is dd/mm/yyy
use this query
 select * from tablename where datefield between convert(datetime,'03/12/2004',103) and convert(datetime,'03/12/2004',103)

if your date format is mm/dd/yyy
then use this query
 select * from tablename where datefield between convert(datetime,'03/12/2004',101) and convert(datetime,'03/12/2004',101)
 
09.14.2005 at 06:32AM PDT, ID: 14880561
I always find that completing the format works best

ie you have

select * from tblstudents where classID='1' and studentstartdate between ('03/12/2004') and ('03/12/2004')

should be

select * from tblstudents where classID='1' and studentstartdate between '03/12/2004 00:00:00' and '03/12/2004 23:59:59'

the add on bits are just hardcoded into the query, with the day being the dynamic element.
 
 
20080236-EE-VQP-29