I have used Emacs' org-mode for a long time to keep track of my hours, and for whatever reason, the following snippet drawn from my actual org-mode file, consistently misreports both Saturday the 11th, and Sunday the 12th.
Looking into it, I find that the hours for Saturday and Sunday are combined into the Saturday entry, at least in the first clocktable. In the second clocktable, which I specifically limited to the dates shown in the logbook, the hours are properly separated out.
I'd appreciate it if anyone could explain what's wrong, as I've never had this happen before, and I really do depend on it for timesheets!
Things Tried
* Re-compiled Emacs 25.1.1 .. just in case a library change was the issue.
* Used 'Packages' to upgrade everything.
* Locally compiled 'git' 2.x since 'magit' was complaining when I updated Packages.
Thanks!
Emacs Version...: GNU Emacs 25.1.1 - Locally compiled.
Org Version.....: 20170210 - Installed via 'Packages'
Operating System: CentOS 7 - From DVD early this year,
and updated as needed.
* FOO
:LOGBOOK:
CLOCK: [2017-03-13 Mon 10:22]--[2017-03-13 Mon 19:17] => 8:55
CLOCK: [2017-03-12 Sun 18:35]--[2017-03-12 Sun 19:17] => 0:42
CLOCK: [2017-03-12 Sun 15:29]--[2017-03-12 Sun 16:23] => 0:54
CLOCK: [2017-03-12 Sun 10:34]--[2017-03-12 Sun 11:18] => 0:44
CLOCK: [2017-03-11 Sat 20:06]--[2017-03-11 Sat 22:59] => 2:53
CLOCK: [2017-03-11 Sat 15:09]--[2017-03-11 Sat 19:15] => 4:06
CLOCK: [2017-03-11 Sat 11:56]--[2017-03-11 Sat 12:32] => 0:36
CLOCK: [2017-03-11 Sat 11:40]--[2017-03-11 Sat 11:56] => 0:16
CLOCK: [2017-03-10 Fri 12:26]--[2017-03-10 Fri 20:10] => 7:44
:LOGBOOK:
** WHERE DID SUNDAY THE 12TH GO?
#+BEGIN: clocktable :maxlevel 9 :scope file :step day :tstart "<-1w>" :tend "<+1d>"
Daily report: [2017-03-07 Tue]
| Headline | Time |
|--------------+--------|
| *Total time* | *0.00* |
Daily report: [2017-03-08 Wed]
| Headline | Time |
|--------------+--------|
| *Total time* | *0.00* |
Daily report: [2017-03-09 Thu]
| Headline | Time |
|--------------+--------|
| *Total time* | *0.00* |
Daily report: [2017-03-10 Fri]
| Headline | Time |
|--------------+--------|
| *Total time* | *7.73* |
|--------------+--------|
| FOO | 7.73 |
Daily report: [2017-03-11 Sat]
| Headline | Time |
|--------------+---------|
| *Total time* | *10.18* |
|--------------+---------|
| FOO | 10.18 |
Daily report: [2017-03-13 Mon]
| Headline | Time |
|--------------+--------|
| *Total time* | *8.92* |
|--------------+--------|
| FOO | 8.92 |
Daily report: [2017-03-14 Tue]
| Headline | Time |
|--------------+--------|
| *Total time* | *0.00* |
Daily report: [2017-03-15 Wed]
| Headline | Time |
|--------------+--------|
| *Total time* | *0.00* |
#+END:
** OH HERE IT IS? BUT WHY?
#+BEGIN: clocktable :maxlevel 9 :scope file :step day :tstart "<2017-03-10>" :tend "<2017-03-14>"
Daily report: [2017-03-10 Fri]
| Headline | Time |
|--------------+--------|
| *Total time* | *7.73* |
|--------------+--------|
| FOO | 7.73 |
Daily report: [2017-03-11 Sat]
| Headline | Time |
|--------------+--------|
| *Total time* | *7.85* |
|--------------+--------|
| FOO | 7.85 |
Daily report: [2017-03-12 Sun]
| Headline | Time |
|--------------+--------|
| *Total time* | *2.33* |
|--------------+--------|
| FOO | 2.33 |
Daily report: [2017-03-13 Mon]
| Headline | Time |
|--------------+--------|
| *Total time* | *8.92* |
|--------------+--------|
| FOO | 8.92 |
#+END:
I'm experiencing a similar problem (for November 2018) and have reported it to emacs-orgmode#gnu.org
Related
I am trying to find the max value of a column, within a date range (by day), within the context of a third column. I'm an SQL newbie, so go easy.
Basically - max value, by day, by cell_id.
Each "Weather_Cell_ID" has data for each hour, for each day. Sample below.
Notice: The are multiple dates
My current PostgreSQL table looks roughly like:
+-----------------+------------------+------------+
| Weather_Cell_ID | Dates | Wind_Speed |
+-----------------+------------------+------------+
| 0001 | 2019-01-21 01:00 | 4.6 |
| 0001 | 2019-01-21 02:00 | 2.4 |
| 0001 | 2019-01-21 04:00 | 8.5 |
| 0001 | 2019-01-22 10:00 | 6.2 |
| 0001 | 2019-01-21 14:00 | 14.8 |
| 0002 | 2019-01-21 01:00 | 3.5 |
| 0002 | 2019-01-21 05:00 | 9.6 |
| 0002 | 2019-01-22 06:00 | 4.8 |
| 0002 | 2019-01-21 16:00 | 12.2 |
| 0002 | 2019-01-21 08:00 | 4.6 |
| 0003 | 2019-01-21 03:00 | 4.9 |
+-----------------+------------------+------------+
My current code looks like:
select weather_cell_id,
date_trunc('day', dates) as dates,
max(windspeed) as maxwindspeed
from view_6day_mat
GROUP BY weather_cell_id, view_6day_mat.dates
order by weather_cell_id
This however produces basically the same table with the HH:MI set to 00:00.
What I'm hoping to see as an output is:
+-----------------+------------+------------+
| Weather_Cell_ID | Dates | Wind_Speed |
+-----------------+------------+------------+
| 0001 | 2019-01-21 | 14.8 |
| 0001 | 2019-01-22 | 6.2 |
| 0002 | 2019-01-21 | 12.2 |
| 0002 | 2019-01-22 | 4.8 |
| 0003 | 2019-01-21 | 4.9 |
+-----------------+------------+------------+
select
weather_cell_id,
dates::date as dates_date,
max(windspeed) as maxwindspeed
from view_6day_mat
GROUP BY weather_cell_id, dates_date
order by weather_cell_id
I had a calender entity in my project which manages the open and close time of business day of the whole year.
Below is the record of a specific month
id | today_date | year | month_of_year | day_of_month | is_business_day
-------+---------------------+------+---------------+-------------+---------------+
10103 | 2016-02-01 00:00:00 | 2016 | 2 | 1 | t
10104 | 2016-02-02 00:00:00 | 2016 | 2 | 2 | t
10105 | 2016-02-03 00:00:00 | 2016 | 2 | 3 | t
10106 | 2016-02-04 00:00:00 | 2016 | 2 | 4 | t
10107 | 2016-02-05 00:00:00 | 2016 | 2 | 5 | t
10108 | 2016-02-06 00:00:00 | 2016 | 2 | 6 | f
10109 | 2016-02-07 00:00:00 | 2016 | 2 | 7 | f
10110 | 2016-02-08 00:00:00 | 2016 | 2 | 8 | t
10111 | 2016-02-09 00:00:00 | 2016 | 2 | 9 | t
10112 | 2016-02-10 00:00:00 | 2016 | 2 | 10 | t
10113 | 2016-02-11 00:00:00 | 2016 | 2 | 11 | t
10114 | 2016-02-12 00:00:00 | 2016 | 2 | 12 | t
10115 | 2016-02-13 00:00:00 | 2016 | 2 | 13 | f
10116 | 2016-02-14 00:00:00 | 2016 | 2 | 14 | f
10117 | 2016-02-15 00:00:00 | 2016 | 2 | 15 | t
10118 | 2016-02-16 00:00:00 | 2016 | 2 | 16 | t
10119 | 2016-02-17 00:00:00 | 2016 | 2 | 17 | t
10120 | 2016-02-18 00:00:00 | 2016 | 2 | 18 | t
I want the get the today_date of last 7 working date. Supporse today_date is 2016-02-18 and date of last 7 working dates as 2016-02-09.
You can use row_number() for this like this:
SELECT * FROM
(SELECT t.*,row_number() OVER(order by today_date desc) as rnk
FROM Calender t
WHERE today_date <= current_date
AND is_business_day = 't')
WHERE rnk = 7
This will give you the row of the 7th business day from todays date
I see that you tagged your question with Doctrine, ORM and Datetime. Were you after a QueryBuilder solution? Maybe this is closer to what you want:
$qb->select('c.today_date')
->from(Calendar::class, 'c')
->where("c.today_date <= :today")
->andWhere("c.is_business_day = 't'")
->setMaxResults(7)
->orderBy("c.today_date", "DESC")
->setParameter('today', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATETIME));
I am trying to transform data from a table of recorded events. I am transforming the data into a consistent 'daily half hour view'. e.g 48 half periods (padding out half hours with zero when there are no matching events), i have completed this with partial success.
SELECT t1.generate_series,
v1.begin_time,
v1.end_time,
v1.volume
FROM tbl_my_values v1
RIGHT JOIN ( SELECT generate_series.generate_series
FROM generate_series((to_char(now(), 'YYYY-MM-dd'::text) || ' 22:00'::text)::timestamp without time zone,
(to_char(now() + '1 day'::interval, 'YYYY-MM-dd'::text) || ' 22:00'::text)::timestamp without time zone, '00:30:00'::interval)
generate_series(generate_series)) t1 ON t1.generate_series = v1.begin_time
order by 1 ;
This provides the following results:
2015-12-19 22:00:00 | 2015-12-19 22:00:00+00 | 2015-12-19 23:00:00+00 | 172.10
2015-12-19 22:30:00 | | |
2015-12-19 23:00:00 | 2015-12-19 23:00:00+00 | 2015-12-20 00:00:00+00 | 243.60
2015-12-20 00:30:00 | | |
2015-12-20 01:00:00 | | |
However based on the 'start' and 'end' columns the view should be:
2015-12-19 22:00:00 | 2015-12-19 22:00:00+00 | 2015-12-19 23:00:00+00 | 172.10
2015-12-19 22:30:00 | | | 172.10
2015-12-19 23:00:00 | 2015-12-19 23:00:00+00 | 2015-12-20 00:00:00+00 | 243.60
2015-12-20 00:30:00 | | | 243.60
2015-12-20 01:00:00 | | |
because the the values in this example span 2 half hours e.g. are valid for one hour.
All help is very welcome. Thanks
Your ON clause is only comparing to the begin_time. I think you want an inequality:
on t1.generate_series between v1.begin_time and t1.end_time
I have the following table:
| Year (Beginn) | Price | Increase |
|---------------+----------+----------|
| 2016 | 20000.00 | 1000.00 |
| 2017 | | 1000.00 |
| 2018 | | 1000.00 |
| 2019 | | 1000.00 |
| 2020 | | 1000.00 |
| 2021 | | 1000.00 |
| 2022 | | 1000.00 |
| 2023 | | 1000.00 |
| 2024 | | 1000.00 |
| 2025 | | 1000.00 |
| 2026 | | 1000.00 |
| 2027 | | 1000.00 |
| 2028 | | 1000.00 |
| 2029 | | 1000.00 |
| 2030 | | 1000.00 |
|---------------+----------+----------|
I want to compute the price recursively such that the final table looks like this:
| Year (Beginn) | Price | Increase |
|---------------+----------+----------|
| 2016 | 20000.00 | 1000.00 |
| 2017 | 22000.00 | 1000.00 |
| 2018 | 24000.00 | 1000.00 |
| 2019 | 26000.00 | 1000.00 |
| 2020 | 28000.00 | 1000.00 |
| 2021 | 30000.00 | 1000.00 |
| 2022 | 32000.00 | 1000.00 |
| 2023 | 34000.00 | 1000.00 |
| 2024 | 36000.00 | 1000.00 |
| 2025 | 38000.00 | 1000.00 |
| 2026 | 40000.00 | 1000.00 |
| 2027 | 42000.00 | 1000.00 |
| 2028 | 44000.00 | 1000.00 |
| 2029 | 46000.00 | 1000.00 |
| 2030 | 48000.00 | 1000.00 |
|---------------+----------+----------|
After reading a related SO question I tried the formula
#+TBLFM: #<<<..>$2=#<<..>>$2+2*$3
but it doesn't work. It gives an error and also seems to operate on column one instead of the specified column two. Any idea how to correctly compute column two? I am using org-mode version 8.2.5c with Emacs version 24.5.1.
I recommend using the following range formula:
| Year (Beginn) | Price | Increase |
|---------------+----------+----------|
| 2016 | 20000.00 | 1000.00 |
| 2017 | | 1000.00 |
| 2018 | | 1000.00 |
| 2019 | | 1000.00 |
| 2020 | | 1000.00 |
| 2021 | | 1000.00 |
| 2022 | | 1000.00 |
| 2023 | | 1000.00 |
| 2024 | | 1000.00 |
| 2025 | | 1000.00 |
| 2026 | | 1000.00 |
| 2027 | | 1000.00 |
| 2028 | | 1000.00 |
| 2029 | | 1000.00 |
| 2030 | | 1000.00 |
|---------------+----------+----------|
#+TBLFM: #<<<$2..#>$2=#<<$0+2*vsum(#<<$3..#-1$3);%.2f
You could write a recursive formula, but that would propogate one row at a time. Even org-table-iterate (C-u C-u C-c * on any table cell) would have to be called more than once, since it stops after 10 iterations.
I'm looking for a way to use time tracking information from org-mode agenda files to build a timetable. Time spent in different tasks would be indicated, grouped by tag and restricted to a given time-frame, sort of like a clocktable dynamic block, but grouped by tag instead of file/category/headline.
For example, if my agenda contained the following data (possibly scattered among different files):
* TODO project 1
** TODO task 1 :tag1:
:LOGBOOK:
CLOCK: [2013-06-27 Thu 18:00]--[2013-06-27 Thu 19:04] => 1:04
CLOCK: [2013-06-26 Wed 17:00]--[2013-06-26 Wed 17:32] => 0:32
:END:
** TODO task 2 :tag2:
:LOGBOOK:
CLOCK: [2013-06-27 Thu 17:00]--[2013-06-27 Thu 18:00] => 1:00
CLOCK: [2013-06-27 Thu 15:00]--[2013-06-27 Thu 15:50] => 0:50
:END:
* TODO project 2 :tag2:
:LOGBOOK:
CLOCK: [2013-06-27 Thu 19:04]--[2013-06-27 Thu 21:00] => 1:56
CLOCK: [2013-06-27 Thu 15:50]--[2013-06-27 Thu 17:00] => 1:10
:END:
I would like to get this kind of results:
#+BEGIN: clocktable-by-tag :maxlevel 2 :tags ("p1" "p2") :tstart "2013-06-27" :tend "2013-06-28"
| Tag | Headline | Time | |
|------+-----------------+--------+------|
| tag1 | *Tag time* | *1:04* | |
| | TODO project 1 | 1:04 | |
| | \__ TODO task 1 | | 1:04 |
|------+-----------------+--------+------|
| tag2 | *Tag time* | *4:56* | |
| | TODO project 1 | 1:50 | |
| | \__ TODO task 2 | | 1:50 |
| | TODO project 2 | 3:06 | |
#+END:
Is there any standard way to do this with org? If not, I'm thinking of cycling through agenda files and tags, using org-get-table-data to collect clocking information; would there be another, more efficient way of doing things?
Here is what I've come to: https://gist.github.com/ffevotte/5899058
It's not very optimized, but seems to get the job done and should support most of the clocktable dynamic block arguments.
Sample (anonymized) output on my real org agenda files:
#+BEGIN: clocktable-by-tag :tags ("p_f3c" "p_sc") :tstart "2013-01-01" :tend "2013-05-19" :maxlevel 2
| Tag | Headline | Time (h) | | |
| | | <r> | | |
|-------+------------------------------+----------+-------+------|
| p_f3c | *Tag time* | *18.42* | | |
| | File *xxx.org* | 18.42 | | |
| | . xxxxxxxxxxxxxxxxxxx | | 13.03 | |
| | . \__ xxxxxxxxxxxxx | | | 7.78 |
| | . \__ xxxxxxxxxxxxxxxxxxxxx | | | 3.98 |
| | . xxxxxxxxxxxxxxxxxx | | 5.38 | |
| | . \__ xxxxxxxxxxxxxxx | | | 5.38 |
|-------+------------------------------+----------+-------+------|
| p_sc | *Tag time* | *18.90* | | |
| | File *yyyy.org* | 4.42 | | |
| | . xxxxxxxxxxxxxxxxxxxxxx | | 2.83 | |
| | . xxxxxxxxxxxxxxxxxx | | 1.58 | |
| | . \__ xxxxxxxxxxxxxxxxxxxxxx | | | 1.58 |
| | File *todo.org* | 14.48 | | |
| | . xxxxxxxxxxxxxxxx | | 14.48 | |
| | . \__ xxxxxxxxxxx | | | 2.00 |
| | . \__ xxxxxxxxxxxxx | | | 8.48 |
| | . \__ xxxxx | | | 4.00 |
#+END:
I have come up with an improvement of this solution that allows for a :summary t option and better formatting of the hours (using org-duration-from-minutes). You can find it in this gist. The result with summarising enabled looks like this:
#+BEGIN: clocktable-by-tag :tags ("work" "client1") :summary t
| Tag | Headline | Time (h) |
|---------+------------+----------|
| work | *Tag time* | 1:29 |
|---------+------------+----------|
| client1 | *Tag time* | 0:45 |
#+END:
Note: I came up with this solution while answering a similar question.