PC Review


Reply
Thread Tools Rate Thread

How can I find records based upon a date and time range while accounting for time zone difference

 
 
BJC
Guest
Posts: n/a
 
      10th Jul 2007
Can someone help me? I need to find all records in a particular table
that occured within the last seven days; but also need to adjust for a
one hour time difference in time zone. The transactions occur in
Central time but are stored on our server at local time (Eastern).

This is the current query we're running to find all the transaction
within the last 7 days, but it does not figure in a time difference of
1 hour for the time zones..... It is automated so we need to use
variables. I need all the records for the last seven days that
occured between 1AM on the first day and 1AM on the last day (example:
between 1 AM on 3/2/07 and 1 AM on 3/9/07).

SELECT dbo_Trans.SiteID, dbo_Sites.SiteDesc, dbo_Trans.ServDate,
dbo_Trans.ID, dbo_Trans.PayType, dbo_Trans.Paid,
CInt(dbo_Trans.UserID)<0 AS UserID
FROM dbo_Trans INNER JOIN dbo_Sites ON dbo_Trans.SiteID =
dbo_Sites.SiteID
WHERE (((dbo_Trans.ServDate)>=Date()-8 And
(dbo_Trans.ServDate)<Date()-1) AND ((dbo_Trans.PayType)=51))
ORDER BY dbo_Trans.ServDate;

I'm sure there's a much better way to accomplish this. Please help.
Thank you!

 
Reply With Quote
 
 
 
 
pietlinden@hotmail.com
Guest
Posts: n/a
 
      10th Jul 2007
On Jul 10, 3:33 pm, BJC <bjc18...@gmail.com> wrote:
> Can someone help me? I need to find all records in a particular table
> that occured within the last seven days; but also need to adjust for a
> one hour time difference in time zone. The transactions occur in
> Central time but are stored on our server at local time (Eastern).
>
> This is the current query we're running to find all the transaction
> within the last 7 days, but it does not figure in a time difference of
> 1 hour for the time zones..... It is automated so we need to use
> variables. I need all the records for the last seven days that
> occured between 1AM on the first day and 1AM on the last day (example:
> between 1 AM on 3/2/07 and 1 AM on 3/9/07).
>
> SELECT dbo_Trans.SiteID, dbo_Sites.SiteDesc, dbo_Trans.ServDate,
> dbo_Trans.ID, dbo_Trans.PayType, dbo_Trans.Paid,
> CInt(dbo_Trans.UserID)<0 AS UserID
> FROM dbo_Trans INNER JOIN dbo_Sites ON dbo_Trans.SiteID =
> dbo_Sites.SiteID
> WHERE (((dbo_Trans.ServDate)>=Date()-8 And
> (dbo_Trans.ServDate)<Date()-1) AND ((dbo_Trans.PayType)=51))
> ORDER BY dbo_Trans.ServDate;
>
> I'm sure there's a much better way to accomplish this. Please help.
> Thank you!


did you look here yet?
http://vbnet.mvps.org/index.html?cod...mezonebias.htm
Yes, it's a VB site, not an Access site, but if you create a function,
you can call it in your query. Then you should be good to go.

 
Reply With Quote
 
Michael Gramelspacher
Guest
Posts: n/a
 
      11th Jul 2007
In article <(E-Mail Removed)>, bjc18722
@gmail.com says...
> Can someone help me? I need to find all records in a particular table
> that occured within the last seven days; but also need to adjust for a
> one hour time difference in time zone. The transactions occur in
> Central time but are stored on our server at local time (Eastern).
>
> This is the current query we're running to find all the transaction
> within the last 7 days, but it does not figure in a time difference of
> 1 hour for the time zones..... It is automated so we need to use
> variables. I need all the records for the last seven days that
> occured between 1AM on the first day and 1AM on the last day (example:
> between 1 AM on 3/2/07 and 1 AM on 3/9/07).
>
> SELECT dbo_Trans.SiteID, dbo_Sites.SiteDesc, dbo_Trans.ServDate,
> dbo_Trans.ID, dbo_Trans.PayType, dbo_Trans.Paid,
> CInt(dbo_Trans.UserID)<0 AS UserID
> FROM dbo_Trans INNER JOIN dbo_Sites ON dbo_Trans.SiteID =
> dbo_Sites.SiteID
> WHERE (((dbo_Trans.ServDate)>=Date()-8 And
> (dbo_Trans.ServDate)<Date()-1) AND ((dbo_Trans.PayType)=51))
> ORDER BY dbo_Trans.ServDate;
>
> I'm sure there's a much better way to accomplish this. Please help.
> Thank you!
>
>

Maybe:

WHERE dbo_Trans.ServDate BETWEEN dateadd("h",1,Dateadd("d", datediff("d",0,now
())-8,0))AND dateadd("h",1,Dateadd("d", datediff("d",0,now())-1,0))
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find records in a field based on a date range - JCW JohnW Microsoft Access Queries 5 22nd Sep 2009 02:53 AM
subtracting date and time to find the difference between the two fluff Microsoft Excel Misc 0 27th May 2009 10:00 PM
Difference between Windows Time Service and Internet Time in Date & Time Properties Saucer Man Windows XP General 0 14th Feb 2008 01:51 PM
Retrieve the records based on the time range Ac Microsoft Access Form Coding 3 4th Jan 2008 05:47 PM
Comparing 2 files on date/time stamp, and based time difference do a subroutine info@stevik.nl Microsoft Excel Programming 1 28th Sep 2007 03:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:14 PM.