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...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com