Find Jobs
Hire Freelancers

Complex datetime differences in PostgreSQL

$30-250 USD

完了済み
投稿日: 10年以上前

$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年前

お金を稼ぎたいですか?

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
お支払い方法確認済み
メンバー登録日:2月 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)
プレビューを読み込み中
位置情報へのアクセスが許可されました。
あなたのログインセッションの有効期限がきれ、ログアウトされました。もう一度ログインしてください。