Why is my location on the world map determined incorrectly?
Select Records between Date/Time & Date/Time?
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > ASP web-programming > Select Records between Date/Time & Date/Time? 13 October 2008 09:37:07

  Recent blog posts: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Select Records between Date/Time & Date/Time?

Greg 13 October 2008 09:37:07
 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

Add comment
Bob Barrows 4 September 2008 00:11:42 permanent link ]
 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.


Add comment
Greg 4 September 2008 00:17:48 permanent link ]
 
"Bob Barrows [MVP]" <reb01501@NOyahoo.S­PAMcom> wrote in message
news:OWvVrmgDJHA.93­6@TK2MSFTNGP03.phx.g­bl...
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.

Add comment
Greg 4 September 2008 00:30:51 permanent link ]
 
"Greg" <greg@redseahookah.­com> wrote in message
news:1107D1CE-324D-­4F39-A723-F42D62CD70­CF@microsoft.com...
"Bob Barrows [MVP]" <reb01501@NOyahoo.S­PAMcom> wrote in message
news:OWvVrmgDJHA.93­6@TK2MSFTNGP03.phx.g­bl...
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...

Add comment
Bob Barrows 4 September 2008 02:50:12 permanent link ]
 Greg wrote:
"Greg" <greg@redseahookah.­com> wrote in message
news:1107D1CE-324D-­4F39-A723-F42D62CD70­CF@microsoft.com...
"Bob Barrows [MVP]" <reb01501@NOyahoo.S­PAMcom> wrote in message
news:OWvVrmgDJHA.93­6@TK2MSFTNGP03.phx.g­bl...
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"


Add comment
Old Pedant 9 September 2008 05:36:01 permanent link ]
 

"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_dat­e+sales_time-1/3) AS theDate, SUM(sales_amount) AS
total
FROM sales_table
GROUP BY DATEVALUE(sales_dat­e+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.


Add comment
Ken 4 October 2008 00:04:57 permanent link ]
 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_tim­e_of_sale, '" &
rsFirstOfSession("d­ate or whatever") & "' ) > -27AND
DATEDIFF(hh,the_tim­e_of_sale, '" & rsFirstOfSession("d­ate 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:52pm, "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

Add comment
Seyfullah IZMIRLI 13 October 2008 09:37:07 permanent link ]
 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-DE0F354FD­F50@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


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > ASP web-programming > Select Records between Date/Time & Date/Time? 13 October 2008 09:37:07

see also:
[Security & JAAS/JBoss] - Re: How can I…
[Installation, Configuration &…
[EJB 3.0] - Re: Database overwritten at…
пройди тесты:
see also:
avast! Virus Cleaner
world's first 10 megapixel multimedia…
Firefox Users to Advise Mozilla

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .