Slut 09:35 09:45 Slut 16:55 17:00 ---------------------------------------
Så det jeg gerne vil lave er en SELECT statement der beregner den tid der skal udfaktureres (BeregnetTid) og returnere den i minutter. Jeg er med på hvordan man bruger DateDiff(). Men kan ikke se en måde at lave det i ren SQL.
Altså fra 08:11 til 09:35 er der jo 7x15mins, kan dette laves?
Min time-tabel ser således ud: Hours: ------------ id StartTime EndTime Name Description ------------
Hmm... When we start an assignment then we start it at each starting quarter, and when we end then we do the same just to the other side. It is to facture out more hours. So you will always as a minimum send a bill on 15mins. If it start(08:10) and end(08:11) then it will be calculated as 08:00->08:15 = 15mins
Is it possible to do such a calculation in a SQL SELECT?
I may be able to put something together whcih works in Access but if you intend using the SQL in ASP or maybe VB then I'mnot sure if it will work. If you save it as a query in Access then you should be able to make a SELECT from the query.
SELECT DatePart("h",[ComeTime])*60+DatePart("n",[ComeTime])-DatePart("n",[ComeTime]) Mod 15 AS ComeInMinutes, DatePart("h",[GoTime])*60+((DatePart("n",[GoTime])+14)-(DatePart("n",[GoTime])+14) Mod 15) AS GoInMinutes, [GoInMinutes]-[ComeInMinutes] AS DiffMinutes FROM tblComeGo;
THis is based on a table named tblComeGo which has two fields ComeTime and GoTime
hmm, not gonna work if the end time is something like 23:55 (24:00) which is calculated as 00:00 so you will get a wrong output. But almost good. I did something like that in ASP, but this one takes care of the 00:00 problem:
Function GetRealQuarters(Mode,Input) GetRealQuarters = ""
If IsDate(Input) Then Dim Result, intMinute intMinute = Minute(Input)
Select Case Mode Case "start": Result = 15*(intMinute\15) Case "end": If intMinute mod 15 > 0 Then Result = 15*((intMinute\15)+1) Else Result = 15*(intMinute\15) End If End Select
If Hour(Input) = 23 And Result = 60 Then GetRealQuarters = cDate(DateSerial(Year(Input),Month(Input),Day(Input)+1) & " 00:00:00") Else GetRealQuarters = cDate(DateSerial(Year(Input),Month(Input),Day(Input)) & " " & TimeSerial(Hour(Input), Result, 0))little End If End If End Function
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.