Find Jobs
Hire Freelancers

Complex datetime differences in PostgreSQL

$30-250 USD

Завершено
Опублікований over 10 years ago

$30-250 USD

Оплачується при отриманні
Hello, I’m working on a PostgreSQL server. I have events which have a start time (timestamp) and an end time (timestamp). I’d like to get a plpgsql function + trigger which computes the elapsed time between those 2 dates, but only counting the BUSINESS HOURS. For this, I have an helper table with a list of days and the relevant business hours. Example: dim_date date opening_hour_start opening_hour_stop 2014-01-01 NULL NULL 2014-02-01 08:00 20:00 2014-03-01 08:00 12:00 2014-04-01 NULL NULL 2014-05-01 NULL NULL 2014-06-01 NULL NULL […] 2014-12-31 NULL NULL When I insert the following events, I expect the following duration (in minutes) will be computed: start_time end_time duration reason None None None Not enough data to compute… 2014-01-01 14:00 None None Not enough data to compute… 2014-01-01 14:00 2014-01-02 05:00 0 The event is during non-business-hours 2014-01-01 14:00 2014-01-02 10:00 02:00:00 2014-01-01 23:59 2014-01-02 10:00 02:00:00 2014-01-02 00:00 2014-01-02 10:00 02:00:00 2014-01-01 14:00 2014-03-01 10:00 14:00:00 2014-01-01 14:00 2014-03-01 23:00 16:00:00 2014-01-01 14:00 2014-12-31 23:00 16:00:00 Those are just some test cases - obviously the function must work for an arbitrary number of entries in dim_date and for an arbitrary duration between start_time and end_time. The deliverables are the SQL code to: - create the table dim_date and its data as defined above - create the table events as defined above - create a function that computes “duration” (plpgsql only please - if you need another language please) - create a trigger which does the job requested. It must only be triggered when start_time or end_time change - run the tests above by inserting new events in the “events” table - of course the results need to be correct ;) - run the tests above by creating an empty event and then doing updates on this event based on the test data above If you feel you need another language than plpgsql, please tell me so. I’m open to all questions of course
ID проекту: 5178795

Про проект

2 пропозицій(-ї)
Дистанційний проект
Активність 10 yrs ago

Хочете заробити?

Переваги подання заявок на Freelancer

Вкажіть свій бюджет та терміни
Отримайте гроші за свою роботу
Опишіть свою пропозицію
Реєстрація та подання заявок у проекти є безкоштовними
Доручений:
Аватарка користувача
Hello, I faced this this on postgress before and i can solve it for you. I will use plpgsql as you requirement. Best regards Thanh
$150 USD за 3 дні(-в)
4,9 (3 відгуки(-ів))
3,3
3,3
2 фрілансерів(-и) готові виконати цю роботу у середньому за $125 USD
Аватарка користувача
I am working on software development since 1992. I am expert on database migration. I can migrate any kind of relational databases with just few SQL sentences. I can solve problems about replacing or combining data related with plugins, modules, themes or components. I have a lot of linux server administrator skills. I have an strong knowledge of server side scripting.
$100 USD за 7 дні(-в)
0,0 (0 відгуки(-ів))
0,0
0,0

Про клієнта

Прапор FRANCE
Thoiry, France
5,0
5
Спосіб оплати верифіковано
На сайті з лют. 22, 2004

Верифікація клієнта

Дякуємо! Ми надіслали на вашу електронну пошту посилання для отримання безкоштовного кредиту.
Під час надсилання електронного листа сталася помилка. Будь ласка, спробуйте ще раз.
Зареєстрованих користувачів Загальна кількість опублікованих робіт
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Завантажуємо для перегляду
Дозвіл на визначення геолокації надано.
Ваш сеанс входу закінчився, і сеанс було закрито. Будь ласка, увійдіть знову.