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:
  #1  
Old June 24th, 2004, 07:39 AM
cmv131 cmv131 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 33 cmv131 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 41 m 24 sec
Reputation Power: 5
Quick query Question

I have a quick question involving a query I need to run.

I have a field on a form that I can only use a calculated SQL command to fill.

The field is going to be a calculated date field. It is based on a selected urgency (which equates to time), and an open date. What I need this new field to be is the sum of these 2 fields, but if it is after 5:00, then it should take the difference between the time it would end at and 5:00, and then add it to 8:00 the next day.

so if the open date is 6/24/04 16:30:00 and the urgency would call for 04:00:00 hours then this new field should come out to 6/25/04 11:30:00

if it is 06/24/04 12:00:00 and 04:00:00 hours then it would show 06/24/04 16:00:00. (this part is easy, but the top part is confusing)

Any help is appreciated

Reply With Quote
  #2  
Old June 30th, 2004, 10:56 AM
Byoung Byoung is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 8 Byoung User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to Byoung
I would think you would handle something like that in your application's code, vbscript/asp whatever your writing it in.

Reply With Quote
  #3  
Old July 1st, 2004, 07:04 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,921 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 12 h 58 m 55 sec
Reputation Power: 1022
you can easily do this with CASE expressions in the sql

by any chance, are you going to want to skip from fridays at 17:00 to mondays at 8:00?

because that makes the expressions a lot more complex
__________________
r937.com | rudy.ca

Reply With Quote
  #4  
Old July 1st, 2004, 07:22 AM
pickledshark pickledshark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Blackpool
Posts: 22 pickledshark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 32 sec
Reputation Power: 0
Send a message via ICQ to pickledshark Send a message via MSN to pickledshark
Use the DATEPART() function to get different parts of your date and as r937 said you can then use CASE Expressions to determine what to do with your date

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Quick query Question


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 3 hosted by Hostway
Stay green...Green IT