How to filter tags to be included/excluded in a clocktable - emacs

I'd like to set up a clocktable where I can specify what tags to include and exclude.
I've tried the below. I've tried with and without double quotes, using + and &, and using :match as well as :tags, nothing seems to work. From the manual it seems that :match should do exactly what I want, but it just includes everything no matter what I do.
#+TAGS: { billable(a) notes(o) travel(b) }
#+BEGIN: clocktable :scope file :tags +"billable"+"notes"-"travel"
#+CAPTION: Clock summary at [2019-09-20 Fri 21:49]
| Headline | Time |
|--------------+--------|
| *Total time* | *1:00* |
|--------------+--------|
| Session | 1:00 |
#+END:
* Session :billable:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 17:30]--[2019-09-19 Thu 18:30] => 1:00
:END:
* Notes :notes:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 18:30]--[2019-09-19 Thu 18:45] => 0:15
:END:
* Travel :travel:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 18:45]--[2019-09-19 Thu 18:55] => 0:10
:END:

I discovered the correct syntax is to have all tags within a single double quote.
:tags "billable|notes-travel"

Since org-mode version 9.2, the :tags argument adds a column with tags when set to t. The argument :match has the old functionality that matches specific tags.
From the changelog,
The :match (renamed from :tags) option allows to limit clock entries to those matching a todo-tags matcher.
The old :tags option can be set to t to display a headline's tags in a dedicated column.

Related

Google Sheet convert time format to another

Whenever I extract raw data from this specific tool I am getting the date format of
Fri Sep 2 10:29:50 2022
Fri Sep 9 10:31:01 2022
Mon Sep 12 10:32:28 2022
and I am having a hard time converting it to this kind of format in Google Sheet
9/2/2022 10:29
9/9/2022 10:31
9/12/2022 10:32
Already tried using different of formating but still can't convert it to the above format.
use:
=ARRAYFORMULA(IF(A1:A5="",,REGEXREPLACE(TRIM(A1:A5),
"(.*) (.*) (.*) (.*) (.*)", "$2/$3/$5 $4")*1))
then do:
Date value
=ArrayFormula(IF(A2:A="",,
DATEVALUE(REGEXEXTRACT(TRIM(A2:A), "(.+\d{1,2}) \d{1,2}:")&" "&REGEXEXTRACT(A2:A, " (....\z)"))+
TIMEVALUE(REGEXEXTRACT(TRIM(A2:A), " (\d{1,2}:\d{1,2}:\d{1,2}) "))))
Custom date and time formats
Custom number formats

Problem with displaying reformatted string into a four-digit year in Stata 17

I turned to a Stata video "Data management: How to create a date variable from a date stored as a string by Chuck Huber" to make sure my date variable were formatted properly, however, I cannot get to show me the reformatted variable (school_year2) to display as a year (e.g. 2018).
Can someone let me know what I may be missing here?
Thank you,
.do file
gen school_year2 = date(school_year,"Y")
format %ty school_year2
list school_year school_year2 in 1/10
+---------------------+
| school~r school~2 |
|---------------------|
1. | 2016 2.0e+04 |
2. | 2016 2.0e+04 |
3. | 2016 2.0e+04 |
4. | 2016 2.0e+04 |
5. | 2016 2.0e+04 |
|---------------------|
6. | 2016 2.0e+04 |
7. | 2016 2.0e+04 |
8. | 2016 2.0e+04 |
9. | 2016 2.0e+04 |
10. | 2016 2.0e+04 |
+---------------------+
.
end of do-file
The value of the underlying data is still days from 1 Jan 1960 as you are using the date() function. So keep %td as you are working with days here, not years. But then you can decide for it to display only the year using %tdCCYY C standing for century and Y for year. But remember, the underlying data point is still the day 1 Jan 2016 and not 2016
clear
input str4 school_year
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
end
gen school_year2 = date(school_year,"Y")
format %tdCCYY school_year2
list school_year school_year2 in 1/10
If year is all you want to work with then use the year() function to get the year from the date. The examples below details steps you can play around with.
clear
input str4 school_year
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
"2016"
end
gen school_year2 = date(school_year,"Y")
gen school_year3 = year(school_year2)
format %tdCCYY school_year2
format %ty school_year3
list in 1/10
Note that in the last example, all values look the same to you. But the first variable is a string with the text "2016", the second is a date stored as the number of days from 1 Jan 1960 with only its year value displayed, and the last is a number with the number of years from year 0 displayed as a year (which in this case would have been the same had it been displayed as its underlying number).
#TheiceBear has already explained the main point, but here is the story told a little differently in case that is helpful.
The fallacy here is that changing the (display) format is just that, a change in format. It has no effect on what is stored, that is, on the value of data held within variables in the question.
You are using generate to create new variables, which is fine, but the basic principles can be seen directly using di (display) on scalar constants. That's also a good way to check understanding of Stata's rules.
The date() function -- despite its historic name -- is for creating numeric daily dates (only). If you tell date() that your input is a string containing the year only, then it imputes 1 January as day and month. The result is an integer, counted from the origin of the scale at 1 January 1960.
. di date("2016", "Y")
20454
. di date("1 Jan 2016", "DMY")
20454
. di date("1 Jan 1960", "DMY")
0
It is a fair bet that few are willing or able to work out what 20454 is on such a scale, but you can specify a daily date display format so that you and readers of your code can see directly.
. di %td 20454
01jan2016
There are many minor variations on that to display daily dates (or parts of them, such as monthly or yearly dates). The different format names for daily dates all start %td.
Conversely, if you say that the value 20454 is to be displayed using a yearly format, you are referring to the year 20454, several thousand years into the future. Stata doesn't act puzzled, except that it doesn't expect such values as years and just shows you a year rounded to 2.0e+04, that is 20000. If you had good reason to work with dates thousands or millions of years into the future, date display formats are likely to be neither needed nor helpful.
. di %ty 20454
2.0e+04
This paper riffs on the idea that a change in display format is only that and that doesn't affect stored values.

Manipulate time on System.DateTime object

I have an small (probably) problem in a function that i am writing. The input to the function is two (start & stop) of the type System.DateTime acquired by the function Get-Date. The output is an array of System.DateTime objects (start & stop) that are between the input objects. Ie.
Start Stop
2018-01-14 13:54:15 2018-01-14 13:54:15
2018-01-15 13:54:15 2018-01-15 13:54:15
Works. However in the process of building this array i need to manipulate the time on the start and stop object and to be honest i havent the slightest clue as to how to set the hour, minute and second on an existing object. Desired output is Ie.
Start Stop
2018-01-14 08:00 2018-01-14 17:00
2018-01-15 08:00 2018-01-15 17:00
I've tried using the ParseExact method but it touches the date as well. I can probably send in more than the time to it, but that seems like 'code from hell' ...
PS C:\tmp> (Get-Date).AddDays(-7)
den 10 januari 2018 14:07:13
PS C:\tmp> [datetime](Get-Date).AddDays(-7)::ParseExact("09:00","hh:mm",$null)
den 17 januari 2018 09:00:00
PS C:\tmp>
How on earth can i manipulate the time, and only the time, on an existing System.DateTime object?
As the function itself serves no real value to the problem it has been excluded.
Use the Date portion of the timestamp, then add the desired number of hours (8 for 8AM, 17 for 5PM):
PS> (Get-Date).Date.AddHours(8)
den 17 januari 2018 08:00:00
your question is not very clear is it what you're looking for ?
$date1=[datetime]"2018-01-14 13:54:15"
PS>$date1.AddSeconds(-15)
Sunday, January 14, 2018 1:54:00 PM

printing 'date' in unix

The command echodate gives output : Sun Aug 20 08:14:50 2017.
I want the date format in : Aug 20.
I tried command : echodate|awk '{print $2, $3}', which outputs to what I want: Aug 20
Is there any other method?
If you look into the date man page, you'll see it's quite capable of delivering what you want without passing the output through a textual filter - you can just use + to specify the output format, such as:
pax> date +"%b %d"
Aug 20

Alternate output format for psql showing one column per line with column name

I am using PostgreSQL 8.4 on Ubuntu. I have a table with columns c1 through cN. The columns are wide enough that selecting all columns causes a row of query results to wrap multiple times. Consequently, the output is hard to read.
When the query results constitute just a few rows, it would be convenient if I could view the query results such that each column of each row is on a separate line, e.g.
c1: <value of row 1's c1>
c2: <value of row 1's c1>
...
cN: <value of row 1's cN>
---- some kind of delimiter ----
c1: <value of row 2's c1>
etc.
I am running these queries on a server where I would prefer not to install any additional software. Is there a psql setting that will let me do something like that?
I just needed to spend more time staring at the documentation. This command:
\x on
will do exactly what I wanted. Here is some sample output:
select * from dda where u_id=24 and dda_is_deleted='f';
-[ RECORD 1 ]------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dda_id | 1121
u_id | 24
ab_id | 10304
dda_type | CHECKING
dda_status | PENDING_VERIFICATION
dda_is_deleted | f
dda_verify_op_id | 44938
version | 2
created | 2012-03-06 21:37:50.585845
modified | 2012-03-06 21:37:50.593425
c_id |
dda_nickname |
dda_account_name |
cu_id | 1
abd_id |
See also:
man psql => \x
man psql => --expanded
man psql => \pset => expanded
(New) Expanded Auto Mode: \x auto
New for Postgresql 9.2; PSQL automatically fits records to the width of the screen. previously you only had expanded mode on or off and had to switch between the modes as necessary.
If the record can fit into the width of the screen; psql uses normal formatting.
If the record can not fit into the width of the screen; psql uses expanded mode.
To get this use: \x auto
Postgresql 9.5 Documentation on PSQL command.
Wide screen, normal formatting:
id | time | humanize_time | value
----+-------+---------------------------------+-------
1 | 09:30 | Early Morning - (9.30 am) | 570
2 | 11:30 | Late Morning - (11.30 am) | 690
3 | 13:30 | Early Afternoon - (1.30pm) | 810
4 | 15:30 | Late Afternoon - (3.30 pm) | 930
(4 rows)
Narrow screen, expanded formatting:
-[ RECORD 1 ]-+---------------------------
id | 1
time | 09:30
humanize_time | Early Morning - (9.30 am)
value | 570
-[ RECORD 2 ]-+---------------------------
id | 2
time | 11:30
humanize_time | Late Morning - (11.30 am)
value | 690
-[ RECORD 3 ]-+---------------------------
id | 3
time | 13:30
humanize_time | Early Afternoon - (1.30pm)
value | 810
-[ RECORD 4 ]-+---------------------------
id | 4
time | 15:30
humanize_time | Late Afternoon - (3.30 pm)
value | 930
How to start psql with \x auto?
Configure \x auto command on startup by adding it to .psqlrc in your home folder and restarting psql. Look under 'Files' section in the psql doc for more info.
~/.psqlrc
\x auto
You have so many choices, how could you be confused :-)? The main controls are:
# \pset format
# \H
# \x
# \pset pager off
Each has options and interactions with the others. The most automatic options are:
# \x off;\pset format wrapped
# \x auto
The newer "\x auto" option switches to line-by-line display only "if needed".
-[ RECORD 1 ]---------------
id | 6
description | This is a gallery of oilve oil brands.
authority | I love olive oil, and wanted to create a place for
reviews and comments on various types.
-[ RECORD 2 ]---------------
id | 19
description | XXX Test A
authority | Testing
The older "\pset format wrapped" is similar in that it tries to fit the data neatly on screen, but falls back to unaligned if the headers won't fit. Here's an example of wrapped:
id | description | authority
----+--------------------------------+---------------------------------
6 | This is a gallery of oilve | I love olive oil, and wanted to
; oil brands. ; create a place for reviews and
; ; comments on various types.
19 | Test Test A | Testing
One interesting thing is we can view the tables horizontally, without folding. we can use PAGER environment variable. psql makes use of it. you can set
export PAGER='/usr/bin/less -S'
or just less -S if its already availble in command line, if not with the proper location. -S to view unfolded lines. you can pass in any custom viewer or other options with it.
I've written more in Psql Horizontal Display
pspg is a simple tool that offers advanced table formatting, horizontal scrolling, search and many more features.
git clone https://github.com/okbob/pspg.git
cd pspg
./configure
make
make install
then make sure to update PAGER variable e.g. in your ~/.bashrc
export PAGER="pspg -s 6"
where -s stands for color scheme (1-14). If you're using pgdg repositories simply install a package (on Debian-like distribution):
sudo apt install pspg
If you are looking for psql command-line mode like me,
here is the syntax --pset expanded=auto
psql command-line options:
-P expanded=auto
--pset expanded=auto
-x
--expanded
...
Another way is -q option ref
Also be sure to check out \H, which toggles HTML output on/off. Not necessarily easy to read at the console, but interesting for dumping into a file (see \o) or pasting into an editor/browser window for viewing, especially with multiple rows of relatively complex data.
you can use the zenity to displays the query output as html table.
first implement bash script with following code:
cat > '/tmp/sql.op';
zenity --text-info --html --filename='/tmp/sql.op';
save it like mypager.sh
Then export the environment variable PAGER by set full path of the script as value.
for example:- export PAGER='/path/mypager.sh'
Then login to the psql program then execute the command \H
And finally execute any query,the tabled output will displayed in the zenity in html table format.