Select Records between Date/Time & Date/Time?

This is a discussion on Select Records between Date/Time & Date/Time? within the Inetserver forums in Microsoft Tools category; I've built a Point-of-Sale using "classic" asp (it's what I know) and I'm trying to get daily sales totals. The problem is sales for the day do not stop at 11:59pm. What is a clean way to select the records from say 8:00am at start of business to 4:00am the next morning? I should be able to figure this out, but I think I've been looking at this too long... Any help would be appreciated! Thanks, Greg...

Go Back   Application Development Forum > Microsoft Tools > Inetserver

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-03-2008, 04:52 PM
Greg
Guest
 
Default Select Records between Date/Time & Date/Time?

I've built a Point-of-Sale using "classic" asp (it's what I know) and I'm
trying to get daily sales totals. The problem is sales for the day do not
stop at 11:59pm. What is a clean way to select the records from say 8:00am
at start of business to 4:00am the next morning? I should be able to figure
this out, but I think I've been looking at this too long...

Any help would be appreciated!

Thanks,
Greg

Reply With Quote
  #2  
Old 09-03-2008, 05:11 PM
Bob Barrows [MVP]
Guest
 
Default Re: Select Records between Date/Time & Date/Time?

Greg wrote:
> I've built a Point-of-Sale using "classic" asp (it's what I know) and
> I'm trying to get daily sales totals. The problem is sales for the
> day do not stop at 11:59pm. What is a clean way to select the
> records from say 8:00am at start of business to 4:00am the next
> morning? I should be able to figure this out, but I think I've been
> looking at this too long...
>
> Any help would be appreciated!
>

It really depends on how the data is stored.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Reply With Quote
  #3  
Old 09-03-2008, 05:17 PM
Greg
Guest
 
Default Re: Select Records between Date/Time & Date/Time?


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OWvVrmgDJHA.936@TK2MSFTNGP03.phx.gbl...
> Greg wrote:
>> I've built a Point-of-Sale using "classic" asp (it's what I know) and
>> I'm trying to get daily sales totals. The problem is sales for the
>> day do not stop at 11:59pm. What is a clean way to select the
>> records from say 8:00am at start of business to 4:00am the next
>> morning? I should be able to figure this out, but I think I've been
>> looking at this too long...
>>
>> Any help would be appreciated!
>>

> It really depends on how the data is stored.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>


The date/time stamps are stored as such.

Reply With Quote
  #4  
Old 09-03-2008, 05:30 PM
Greg
Guest
 
Default Re: Select Records between Date/Time & Date/Time?


"Greg" <greg@redseahookah.com> wrote in message
news:1107D1CE-324D-4F39-A723-F42D62CD70CF@microsoft.com...
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:OWvVrmgDJHA.936@TK2MSFTNGP03.phx.gbl...
>> Greg wrote:
>>> I've built a Point-of-Sale using "classic" asp (it's what I know) and
>>> I'm trying to get daily sales totals. The problem is sales for the
>>> day do not stop at 11:59pm. What is a clean way to select the
>>> records from say 8:00am at start of business to 4:00am the next
>>> morning? I should be able to figure this out, but I think I've been
>>> looking at this too long...
>>>
>>> Any help would be appreciated!
>>>

>> It really depends on how the data is stored.
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get a
>> quicker response by posting to the newsgroup.
>>
>>

>
> The date/time stamps are stored as such.
>


Seperately that is...

Reply With Quote
  #5  
Old 09-03-2008, 07:50 PM
Bob Barrows [MVP]
Guest
 
Default Re: Select Records between Date/Time & Date/Time?

Greg wrote:
> "Greg" <greg@redseahookah.com> wrote in message
> news:1107D1CE-324D-4F39-A723-F42D62CD70CF@microsoft.com...
>>
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:OWvVrmgDJHA.936@TK2MSFTNGP03.phx.gbl...
>>> Greg wrote:
>>>> I've built a Point-of-Sale using "classic" asp (it's what I know)
>>>> and I'm trying to get daily sales totals. The problem is sales
>>>> for the day do not stop at 11:59pm. What is a clean way to select
>>>> the records from say 8:00am at start of business to 4:00am the next
>>>> morning? I should be able to figure this out, but I think I've
>>>> been looking at this too long...
>>>>
>>>> Any help would be appreciated!
>>>>
>>> It really depends on how the data is stored.
>>>
>>>
>>>

>>
>> The date/time stamps are stored as such.
>>

>
> Seperately that is...


More details please:
database type and version
table name
fieldnames and datatypes

It helps to include a few rows of sample data followed by desired results

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Reply With Quote
  #6  
Old 09-08-2008, 10:36 PM
Old Pedant
Guest
 
Default RE: Select Records between Date/Time & Date/Time?



"Greg" wrote:

> I've built a Point-of-Sale using "classic" asp (it's what I know) and I'm
> trying to get daily sales totals. The problem is sales for the day do not
> stop at 11:59pm. What is a clean way to select the records from say 8:00am
> at start of business to 4:00am the next morning? I should be able to figure
> this out, but I think I've been looking at this too long...


You ever figure this out??? It's not hard, but you goofed by putting the
data and time into separate fields in the DB. Now you just have to lump them
back together.

And what do you do about times between 4AM and 8AM????

Yeah, I know...the store is closed. Want to be that someday somebody sells
something at 4:03 AM??

Anyway, fortunately in Access you can just add a time to a date to get a
date/time value. And I'm going to assume that your "days" really run from
8AM to 7:59:59 AM.

SO...

SELECT DATEVALUE(sales_date+sales_time-1/3) AS theDate, SUM(sales_amount) AS
total
FROM sales_table
GROUP BY DATEVALUE(sales_date+sales_time-1/3)
ORDER BY 1

Now, that's a hacky trick: In Access, dates and times are represented as
the number of days since 12/30/1899. Dates are the whole integer number of
days. Times are the fractional part of a day. So when I do
-1/3
I am subtracting 1/3 of a day--which is 8 hours--from the sum of the date
and time. That is, I am adjusting the effective date *backwards* by 8 hours.

If this really offends you sensibilities, you can use DATEADD instead:

DATEVALUE( DATEADD( 'h', -8, sales_date + sales_time ) )

But next time, don't store the date and time in separate fields in the DB.
In any DB but Access, you'd make the whole thing a lot harder.


Reply With Quote
  #7  
Old 10-03-2008, 05:04 PM
KEN
Guest
 
Default Re: Select Records between Date/Time & Date/Time?

I like to use the DataDiff function in SQL

SELECT * FROM table WHERE the_time_of_sale = (SELECT Max(time_of_sale)
from table WHERE DATEDIFF(hh,the_time_of_sale, '" &
rsFirstOfSession("date or whatever") & "' ) > -27AND
DATEDIFF(hh,the_time_of_sale, '" & rsFirstOfSession("date or
whatever") & "' ) > -3);"'

So that would give you everything not more than 27 before hours from
the date entered and not more than 3 hours ahead.

And that first of session could be today's date or user input
whatever.



On Sep 3, 2:52*pm, "Greg" <g...@redseahookah.com> wrote:
> I've built a Point-of-Sale using "classic" asp (it's what I know) and I'm
> trying to get daily sales totals. *The problem is sales for the day do not
> stop at 11:59pm. *What is a clean way to select the records from say 8:00am
> at start of business to 4:00am the next morning? *I should be able to figure
> this out, but I think I've been looking at this too long...
>
> Any help would be appreciated!
>
> Thanks,
> Greg


Reply With Quote
  #8  
Old 10-13-2008, 02:37 AM
Seyfullah IZMIRLI
Guest
 
Default Re: Select Records between Date/Time & Date/Time?

If i were you, i'll use DateTime as Float...
for example.

SELECT <NEEDED FIELDS>
FROM <TABLE>
WHERE <FILTEREDDATE> > CAST(39732,39990 AS DATETIME)

with this case i would use the limitation as seconds

Have fun with SQL

Seyfullah IZMIRLI

"Greg" <greg@redseahookah.com>, haber iletisinde sunlari
yazdi:A7F9400E-81D7-443E-A9B7-DE0F354FDF50@microsoft.com...
> I've built a Point-of-Sale using "classic" asp (it's what I know) and I'm
> trying to get daily sales totals. The problem is sales for the day do not
> stop at 11:59pm. What is a clean way to select the records from say
> 8:00am at start of business to 4:00am the next morning? I should be able
> to figure this out, but I think I've been looking at this too long...
>
> Any help would be appreciated!
>
> Thanks,
> Greg
>



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:59 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.