.NETGURU
What do I need to select based on date only How do i convert the datetime to date..
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.


Dennis West
what do I need to select base on date only How do i convert the datetime to date..

string SQL = "Select ID, Problem, Create_Date,Version,Poll from dwKnowledgeBase_ where Lang = '" + Lang + "' and Create_Date < ( Convert(datetime,convert(varchar,getdate(), 1)) ) AND Create_date > (Convert(datetime,convert(varchar,getdate(), 1))-1) order by category";

For 2002 ASP.NET Solutions & Articles goto:
http://aspalliance.com/dotnetsolutions/

Dennis West
West Design
MS .NET Developer
www. westontheweb.net
Click here to reveal e-mail address
Reply to this message...
 
    
James Avery
CAST(Convert(varchar(10), Create_Date, 101) as datetime) <
CAST(Convert(varchar(10), getdate(), 101) as datetime)

It works but it might not be the most efficient way.

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Friday, July 19, 2002 4:29 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] What do I need to select based on date only
How do i convert the datetime to date..

what do I need to select base on date only How do i convert the datetime
to date..

string SQL = "Select ID, Problem, Create_Date,Version,Poll from
dwKnowledgeBase_ where Lang = '" + Lang + "' and Create_Date < (
Convert(datetime,convert(varchar,getdate(), 1)) ) AND Create_date >
(Convert(datetime,convert(varchar,getdate(), 1))-1) order by category";

For 2002 ASP.NET Solutions & Articles goto:
http://aspalliance.com/dotnetsolutions/

Dennis West
West Design
MS .NET Developer
www. westontheweb.net
Click here to reveal e-mail address

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
Reply to this message...
 
    
Dennis West
MessageI converted the statement per your suggestion but i still return all the records for the last seven days it seems the group by is not working, what I am looking to do is return 7 records one for each of the last days with the total records for each day. At this point I am getting all the records for each day with a count of 1.

Select count(Create_Date), Create_Date from dwDNS_ where Create_Date < Cast(Convert(varchar(10), getdate(), 101) as datetime)AND Create_date > CAST(Convert(varchar(10), getdate(), 101) as datetime)-7 Group By Create_Date
----- Original Message -----
From: James Avery
To: ngfx-sqlclient
Sent: Friday, July 19, 2002 6:51 AM
Subject: [ngfx-sqlclient] RE: What do I need to select based on date only How do i convert the datetime to date..

CAST(Convert(varchar(10), Create_Date, 101) as datetime) < CAST(Convert(varchar(10), getdate(), 101) as datetime)

It works but it might not be the most efficient way.
-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Friday, July 19, 2002 4:29 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] What do I need to select based on date only How do i convert the datetime to date..

what do I need to select base on date only How do i convert the datetime to date..

string SQL = "Select ID, Problem, Create_Date,Version,Poll from dwKnowledgeBase_ where Lang = '" + Lang + "' and Create_Date < ( Convert(datetime,convert(varchar,getdate(), 1)) ) AND Create_date > (Convert(datetime,convert(varchar,getdate(), 1))-1) order by category";

For 2002 ASP.NET Solutions & Articles goto:
http://aspalliance.com/dotnetsolutions/

Dennis West
West Design
MS .NET Developer
www. westontheweb.net
Click here to reveal e-mail address

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
Reply to this message...
 
    
James Avery
You need to covert the group by also....

Group By Convert(varchar(10), Create_Date, 101)

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Friday, July 19, 2002 9:12 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE: What do I need to select based on date
only How do i convert the datetime to date..

I converted the statement per your suggestion but i still return all the
records for the last seven days it seems the group by is not working,
what I am looking to do is return 7 records one for each of the last
days with the total records for each day. At this point I am getting all
the records for each day with a count of 1.

Select count(Create_Date), Create_Date from dwDNS_ where Create_Date <
Cast(Convert(varchar(10), getdate(), 101) as datetime)AND Create_date >
CAST(Convert(varchar(10), getdate(), 101) as datetime)-7 Group By
Create_Date

----- Original Message -----
From: James <mailto:Click here to reveal e-mail address> Avery
To: ngfx-sqlclient <mailto:Click here to reveal e-mail address>
Sent: Friday, July 19, 2002 6:51 AM
Subject: [ngfx-sqlclient] RE: What do I need to select based on date
only How do i convert the datetime to date..

CAST(Convert(varchar(10), Create_Date, 101) as datetime) <
CAST(Convert(varchar(10), getdate(), 101) as datetime)

It works but it might not be the most efficient way.

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Friday, July 19, 2002 4:29 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] What do I need to select based on date only
How do i convert the datetime to date..

what do I need to select base on date only How do i convert the datetime
to date..

string SQL = "Select ID, Problem, Create_Date,Version,Poll from
dwKnowledgeBase_ where Lang = '" + Lang + "' and Create_Date < (
Convert(datetime,convert(varchar,getdate(), 1)) ) AND Create_date >
(Convert(datetime,convert(varchar,getdate(), 1))-1) order by category";

For 2002 ASP.NET Solutions & Articles goto:
http://aspalliance.com/dotnetsolutions/

Dennis West
West Design
MS .NET Developer
www. westontheweb.net
Click here to reveal e-mail address

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT
Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification