Free2Code
 
Time: 2008-11-21, 09:44pm
ADO woes!
Subject: ADO woes!  ·  Posted: 2005-08-23, 01:16pm
Rank: ? (1224)
Member #: 15685
Hy guys...i have a big problem here

Im currently using ADO to call out my database in MS Access and using ASP to display it. The problem now is i need to call out a certain range of data from between two dates. And to note the dates also has the time written with it...do its a "date and time format"

Code:
  1. set rs = server.createObject( "ADODB.Recordset" )
  2. SQL = "SELECT withdraw_date,withdraw_qty FROM Withdraw_history WHERE withdraw_date BETWEEN #" & monthFrom & " 12:00:00 AM# AND #" & monthto & " 11:59:59 PM#"  
  3. rs.open SQL,cn,3


now i need to group them up by the date and only the date....but it seems to be grouping them up into date and time as well

Any ideas? Any help here would be appreciated

» Post edited 2005-08-23, 01:17pm by Viper55.

Stick and Stones may break my bones but Caricatures will cause a riot!
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-24, 06:54am
Rank: ? (4821)
Member #: 3416
where are you grouping it? i don't see any grouping in your query...

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-24, 12:11pm
Rank: ? (1224)
Member #: 15685
Oh Sorry...im grouping it at the SQL statement so the SQL would be like this

Code:
  1. set rs = server.createObject( "ADODB.Recordset" )
  2. SQL = "SELECT withdraw_date,withdraw_qty FROM Withdraw_history WHERE withdraw_date BETWEEN #" & monthFrom & " 12:00:00 AM# AND #" & monthto & " 11:59:59 PM GROUP BY withdraw_date#"   
  3. rs.open SQL,cn,3

The thing is the withdraw_date has date and time.....if i did that then it would group by the time as well....i was hoping i could just group the date and leave out the time

Stick and Stones may break my bones but Caricatures will cause a riot!
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-25, 01:20am
Rank: ? (4821)
Member #: 3416
you should be able to use your withdraw_date field, but not directly. you can actually use a formula to group by, and i think access stores date/time the way excel does: the number of days since 12/31/1899, with a fractional part for the time.

you could try something like 'group by trunc(withdraw_date)' but i'm not sure if trunc() is a function that access supports. you would probably need to look up a truncate function for access and use that.

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-25, 05:37pm
Rank: ? (1224)
Member #: 15685
Code:
  1. SELECT distinct CDate(Int([datefield])) AS Expr1 FROM table1;


i got this solution from the net and CDate does only take out the date and strips of the time....but its only for display purposes im afraid.....still cant group by using the CDate.....Know what distinct does?

Stick and Stones may break my bones but Caricatures will cause a riot!
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-26, 02:50am
Rank: ? (4821)
Member #: 3416
distinct means it won't select multiple rows witht he same data. you don't need it if you're using a group by. if it won't let you use functions in your group by clause, you can try something like this:

1. select the date as a column, "CDate(Int([withdraw_date])) as withdraw_date_no_time" gets added to your select clause
2. group by the name of that column, "group by withdraw_date_no_time"

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-28, 02:19pm
Rank: ? (1224)
Member #: 15685
Doesnt work tho....i got errors....it doesnt seem to accept the withdraw_date_no_time as a valid group by field

Stick and Stones may break my bones but Caricatures will cause a riot!
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-29, 01:41am
Rank: ? (4821)
Member #: 3416
well i'm out of ideas then, unless you can switch to a better database

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: ADO woes!  ·  Posted: 2005-08-29, 12:11pm
Rank: ? (1224)
Member #: 15685
hmmm well there is another longer way i could try i guess.....thanks for the help

Stick and Stones may break my bones but Caricatures will cause a riot!
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons