Solved

Make time using event offsets in sql or excel

Posted on 2012-03-16
3
279 Views
Last Modified: 2012-03-16
Shift and events
Above is an image of a table containing events occuing during a shift. I have a start time and an end time for the shift but I am trying to convert the fields "StartOffset" and "StopOffset" into time. I've used some contacts along with the floor function to create time but that off set represented minutes from midnight (0 = 12:00:00 AM). I thought I could maybe use the same approach but instead using the ShiftStartTime as my floored time. Didnt work. Any assistance with this would be much appreciated.
0
Comment
Question by:spaced45
  • 2
3 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37731573
If this is one-time then you can follow the following steps.

Enter a value 1440 in any blank cell
Select the cell
Ctrl-c
select the start and stop data (without headers)
paste-special with "Divide" option
OK
Select shift start data (without headers)
Ctrl-c
select the start and stop data (without headers)
paste-special with "Add" option
OK
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 37731600
The same has been programmed in a macro.

Sub timeoffsets()
Dim cel As Range, tgt As Range
Set cel = ActiveSheet.Cells.SpecialCells(xlCellTypeBlanks).Cells(1, 1)
cel.Value = 1440
cel.Copy
Set tgt = ActiveSheet.Range("D2:E" & ActiveSheet.Range("D2").End(xlDown).Row)
tgt.PasteSpecial , operation:=xlPasteSpecialOperationDivide
ActiveSheet.Cells.SpecialCells(xlCellTypeBlanks).Cells(1, 1).Select
cel.ClearContents
tgt.Offset(, -2).Resize(, 1).Copy
tgt.PasteSpecial , operation:=xlPasteSpecialOperationAdd
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:spaced45
ID: 37731836
Worked Great!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Viewers will learn how the fundamental information of how to create a table.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now