I have gotten so much help form this forum from times to times, but this is the first time I am posting a question.
What I need is:
I have an excel file that is extracted from a machine, which records temperatures every 15 minutes per hour, 24 hours per day, every day per month... (96 rows per day)
In Column A we have the dates
01/09/2017 (x96 times)
02/09/2017 (x96 times)
...
...
...
30/09/2017 (x96 times)
Sometimes this machine gets stuck and stops recording, so until it gets back to work and start recording again, I have already missed some records, which I have to enter by hand.
So, I need a macro, to check if each date of the month has 96 rows in column A and if not then add the missing rows... It happens some dates to have 70 rows, so in that case I need the macro to insert another 26 rows of the same date...
I don't know if this is easy, but it would be very helpful if someone could give me a solution.
I have a table of data that data that contains a date, time-in, and time-out pulled from a postgresql db table. Currently the table shows the time a person checked in, and out over a period of hours. I need to use postgresql to split out the hours between time-in and time-out such that I capture each full hour (eg. 10am-11am) and each fraction (eg. 4.15pm to 5pm) of the hour during which that person was checked in. So if a person checked in at 9.30am, took a 1 hour lunch break at 12, and checked out at 4.30pm, my current table would show two rows for that member i.e. one row for the time before lunch break, and the time after the lunch break. I want to show each hour (whole or partial) on each row, with 1 representing that 1 whole hour, and the minute portion to capture the partial hour worked.
Below are the before and after images. Any help is appreciated.
Shows that I want to convert from
Shows that I want to convert to
Thanks
try this.
CAST(time_out - time_in AS TIME)
I'm going through this list of dates and times and I've been googling for a few days now and haven't figured out this time format:
201612102200038814 -> 10.12.2016 19:01
201611182200029224 -> 18.11.2016 11:55
201611162200028449 -> 16.11.2016 19:06
2016080521998919 -> 5.8.2016 19:47
2016091522320593 -> 15.9.2016 18:53
It's obvious that the first 8 digits (20161210) are YYYYMMDD, but latter part doesn't make any sense to me....
Do you have any ideas? Is it even a valid time format?
It seems to be some kind of timestamp, since 2,200,029,224 is very close to 2,200,028,449, and the dates of each are only 2 days apart. So the difference is 775, and the date difference is roughly 1.75 days.
The difference between the first two is 9590, which is larger, which makes sense since the difference between those dates is almost a month.
The oldest date you have in the list also has the smallest timestamp, which is consistent with this theory.
The ratios also match up. 775 / 1.75 days = 442. 9590 / 22 days = 435. If I calculated exact seconds differences I bet these ratios would match up nearly perfectly. So then each hour the timestamp goes up by 18 (roughly), or 3 every 10 minutes. This is a pretty bizarre timestamp, but it does fit, and can be used to calculate dates from the given timestamp.
I try to represent date objects in a data storage without the hassle of Date object in Java. So I thought of using just a time in milliseconds and store the UTC time zone as well. I thought about using simple shift routines to combine everything in a single long as time zone is just 5bits (+/-12).
Can someone see any problem with this? What other compact storage schemes (other than textual representation) of date exist and how do they compare to this?
I think you're under valuing granularity in your time zone and over valuing the need for bits in the timestamp.
A long has has 8 bytes for this purpose.
Lets say you allow yourself 2 bytes for the time zone. That leaves you with 6 for the timestamp. 6*8 = 48 bits for a timestamp.
The largest number a 48 bit unsigned integer can handle is 281474976710655.
Divide by 1000 to get from miliseconds to seconds 281474976710
Punch that number into an epoch converter: 10889-08-02T05:31:50+00:00
That's the year 10,889 when we're in 2,015.
Just use 2 bytes for the timezone. You've got the space. That will easily allow you to represent the timezone as minutes offset +-24 hours. And since it's whole bytes, the packing code will be simpler to comprehend.
I have data from a text file I'm reading into a postgres 9.1 table, and the data looks like this:
451,22:30:00,22:30:00,San Jose,1
451,22:35:00,22:35:00,Santa Clara,2
451,22:40:00,22:40:00,Lawrence,3
451,22:44:00,22:44:00,Sunnyvale,4
451,22:49:00,22:49:00,Mountain View,5
451,22:53:00,22:53:00,San Antonio,6
451,22:57:00,22:57:00,California Ave,7
451,23:01:00,23:01:00,Palo Alto,8
451,23:04:00,23:04:00,Menlo Park,9
451,23:07:00,23:07:00,Atherton,10
451,23:11:00,23:11:00,Redwood City,11
451,23:15:00,23:15:00,San Carlos,12
451,23:18:00,23:18:00,Belmont,13
451,23:21:00,23:21:00,Hillsdale,14
451,23:24:00,23:24:00,Hayward Park,15
451,23:27:00,23:27:00,San Mateo,16
451,23:30:00,23:30:00,Burlingame,17
451,23:33:00,23:33:00,Broadway,18
451,23:38:00,23:38:00,Millbrae,19
451,23:42:00,23:42:00,San Bruno,20
451,23:47:00,23:47:00,So. San Francisco,21
451,23:53:00,23:53:00,Bayshore,22
451,23:58:00,23:58:00,22nd Street,23
451,24:06:00,24:06:00,San Francisco,24
It is from a timetable for a commuter rail line, Caltrain. I'm trying to query stations, to get train arrival and departure times. I did this several months ago in MySql, and I got
select * from trains as a, trains as b where a.trip_id=b.trip_id and a.st
op_id='San Antonio' and b.stop_id='San Carlos' and a.arrival_time < b.arrival_ti
me;
So far so good, pretty straightforward. However, when I tried copying the data into a postgres database, I got an error for the various columns that had times after midnight, either 24 or 25:00:00 something. However, if I change them to be 00:00:00 and 01:00:00 something, won't that mess with the query? A time after midnight will appear to be before the starting time? MySql apparently didn't have a problem with those times, and I'm not sure what to do. I'm thinking I should use the last column, or maybe convert the times to something that doesn't take into account PM/AM?
You should try using the interval type for the time columns. Those will keep track of the number of hours, minutes, and seconds instead of trying to record a time of day.
See the PostgreSQL documentation on dates and times.
An interval can have a time component greater than 24 hours, unlike the time datatype that is confined to 00:00 <= x <= 23:59.