SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

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 Tutorialized Forums Sponsor:
  #1  
Old January 9th, 2013, 06:02 AM
williams485 williams485 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 williams485 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 53 sec
Reputation Power: 0
Convert time to float/integer

Hello,
I'm using an SQL query within a VBA application that accesses a database. Specifically, I'm building a list of employees (contact), total hours this month, and total hours last month.
I've done some reading and compiled the following query ('tmStart','TMEnd','LMStart' and 'LMEnd' are all date variables).

Code:
SELECT TM.contact, TM_duration, LM_duration
FROM (SELECT C1.contact, sum(CH.duration) AS TM_duration
         FROM contact1 AS C1
           INNER JOIN conthist AS CH
             ON C1.accountno = CH.accountno
         WHERE CH.resultcode = 'AS'
           AND C1.key3 = '8.1n Training'
           AND CH.ondate BETWEEN #tmStart# AND #TMEnd#
         GROUP BY C1.contact) AS TM
INNER JOIN (SELECT C1.contact, sum(CH.duration) AS LM_duration
                 FROM contact1 AS C1
                 INNER JOIN conthist AS CH
                   ON C1.accountno = CH.accountno
                 WHERE C1.key3 = '8.1n Training'
                   AND CH.ondate BETWEEN #LMStart# AND #LMEnd#
                 GROUP BY C1.contact) AS LM
ON TM.contact = LM.contact


The problem is that the CH.duration field stores times as hh:mm:ss but as a string (according to the documentation for our CRM system - Goldmine 6.7), which is incompatible with the SUM() function. When I've tried using a CONVERT() function, I get an error.

Does anyone have a solution or some helpful advice on this one?

Thanks

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > Convert time to float/integer


Developer Shed Advertisers and Affiliates


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 | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap