MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 2nd, 2004, 01:35 AM
ixmark ixmark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 ixmark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Join/Union or Other

I have a table that has a Time & Date column. I have them being combined on the select statement and I need to subtract 8 hours from the start time. This is an example of the current Select Statement

SELECT dateadd(hh, -8, air_date + air_time) AS theTime, station_num, database_key

This gives me the correct information but since I subtracted 8 hours I get data from the day before.

Example
SELECT dateadd(hh, -8, air_date + air_time) AS theTime, station_num, database_key
FROM table
WHERE theTime >= '2004-04-11' AND theTime <= '2004-04-12'

Airtime Airdate Output Info
8:00 AM 3/31/2004 12:00 AM 3/30/2004
4:00 PM 3/31/2004 8:00 AM 3/31/2004


Etc Etc

So on the first one since it starts at 8:00am It goes to the day before from subtracting the time.

I also have it changing the time on the insert form the flatfile. If this is a better way how should I deal with if its DST or not.


I hope all this makes sense and any help would be appreciated.

Mark

Reply With Quote
  #2  
Old April 2nd, 2004, 05:46 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,149 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 4 Days 14 h 39 m 56 sec
Reputation Power: 883
what are the datatypes of the Time & Date columns, please?

do you have a reason for carrying them as separate fields?
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old April 2nd, 2004, 12:28 PM
ixmark ixmark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 ixmark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is the structure

Airdate datetime
Airtime Varchar(50)

They are in separate columns because that’s the way I get the data. I can combine them on the insert if needed. Right now I started subtracting the time in the DTS package I wrote. The problem is my data goes out 6 weeks so when it over laps daylight saving time I becomes an hour off.


Thanks
Mark

Reply With Quote
  #4  
Old April 2nd, 2004, 12:35 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,149 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 4 Days 14 h 39 m 56 sec
Reputation Power: 883
"because that’s the way I get the data"

been there, got the t-shirt

"This gives me the correct information but since I subtracted 8 hours I get data from the day before."

okay, if dateadd(hh, -8, air_date + air_time) is correct (i.e. no syntax error or anything), then i don't understand the problem

Reply With Quote
  #5  
Old April 2nd, 2004, 12:46 PM
ixmark ixmark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 ixmark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I’m sorry I guess I didn’t make the problem clear.

If a user selects that they only want to see content on a certain day lets say 4/1/04 and they submit the form. Right now its set in SQL like so.

Select dateadd(hh, -8 ,col1 + col2) AS air_date
From table
Where air_date = ‘selected_day’

So here I have taken off 8 hours for the start date and start time. Since they selected 4/1/04 in the form anything that starts before 8am is really yesterdays program not today’s cause I have taken off 8 hours.

I need it to subtract the time first then allow me to choose the date selected by the user.

Thanks
Mark

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Join/Union or Other


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway