How to make agenda view show tasks deadlined tomorrow or another number of days ahead? - org-mode

I want to make my org agenda view to show separate blocks for tasks deadlined for today, for tomorrow, and for a sertain number of days ahead. I have tried the following code:
(setq org-agenda-custom-commands '(
("d" "deadlined tasks"(
(tags-todo "+TODO={NEXT}+DEADLINE>=\"<Today>\" " (
(org-agenda-sorting-strategy '(scheduled-down))
(org-agenda-overriding-header "Deadline today")
))
(tags-todo "+TODO={NEXT}+DEADLINE>=\"<Today>\"+1 " (
(org-agenda-sorting-strategy '(scheduled-down))
(org-agenda-overriding-header "Deadline tomorrow")
))
(tags-todo "+TODO={NEXT}+DEADLINE>=\"<Today>\"+2 " (
(org-agenda-sorting-strategy '(scheduled-down))
(org-agenda-overriding-header "Deadline in two days")
))
))
What is wrong in my code? How can I filter out tasks deadlined for n number of days ahead?

You can try org-super-agenda.
With org-super-agenda, you just need to set:
(let ((org-super-agenda-groups
'(;; Each group has an implicit boolean OR operator between its selectors.
(:name "Deadline Future"
:deadline future)))))
For more usages of org-super-ageda, you can check the examples.
:deadline
Group items that have a deadline. Argument can be t (to match items with any deadline), nil (to match items that have no deadline), past (to match items with a deadline in the past), today (to match items whose deadline is today), or future (to match items with a deadline in the future). Argument may also be given like before DATE or after DATE where DATE is a date string that org-time-string-to-absolute can process.

Related

Tableau: How do I convert date to month-week #?

I have a date column. For example, the date is 8/2/2022, I'm hoping to see that this will convert to Aug Week 1; and if let's say the date is 7/15/2022, then the result should say July Week 3.
Please help, thanks!
You need to use LOD to do so, as default, you can only do week numbers by year in tableau, you need to create two calculated field to do so:
1.Create a [Min-Week] calculation field as shown below:
{ FIXED MONTH([Date]):MIN(DATEPART('week',[Date]))}
Note the calculation above for [Min-Week] assumes that there is at least one record for the first week of each month. If your data does not allow you to rely on that assumption, you could instead use DATEPART('week', DATETRUNC('month', [Date]))
2.Create a [Week-By-Mth] calculation field as shown below :
CASE DATEPART('week',[Date]) WHEN [Min-Week] THEN "Week 1" WHEN [Min-Week]+1 THEN "Week 2" WHEN [Min-Week]+2 THEN "Week 3" WHEN [Min-Week]+3 THEN "Week 4" WHEN [Min-Week]+4 THEN "Week 5" WHEN [Min-Week]+5 THEN "Week 6" END
EDIT good answer - here's just a shorter equivalent expression for [Week-By-Mth]
"Week " + STR(DATEPART('week, [Date]) - [Min-Week] + 1)
If you prefer an integer to a string, you could simplify further by getting rid of the Week prefix and the STR() call.
The [Week-By-Mth] calculation field should be what you need.

Array of start and end dates where the proceeding start date = the previous end date +1 WORKDAY

Is it possible to make two columns of dates (start and end) with only the initial start date and number of days for each task using a single formula? I can drag formulas down, but I'd rather have the flexibility of an ARRAYFORMULA, if at all possible.
I have a list of tasks (that will be ever-changing) with a number of days to complete each task. I also have a definite start date. I can get my end dates using WORKDAY
=ArrayFormula(IF(LEN(B2:B),WORKDAY.INTL(C2:C-1,B2,6,),))
, but trying to automatically populate the next start days always results in a circular reference.
=ArrayFormula(WORKDAY.INTL(C2:C,B2:B,6,))
The next problem is in the [weekend] variable of the WORKDAY function. Since my following start dates don't always fall on the same day, "6" is not always accurate, causing weekends to inadvertently appear as valid workdays.
Here's my test sheet
why not do it like this:
paste in cell D2:
=ARRAYFORMULA(FILTER(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7'"),
IF(REGEXMATCH(TO_TEXT(ROW(INDIRECT("A1:A"&COUNTA(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7'"))))), "^"&JOIN("$|^",
IF(A2:A="",,MMULT(TRANSPOSE((ROW(A2:A)<=TRANSPOSE(ROW(A2:A)))*(B2:B)),
SIGN(B2:B))))&"$"), "♀", )="♀"))
paste in cell C3:
=ARRAYFORMULA(IF(A3:A="",,FILTER(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7'"),
IF(REGEXMATCH(TO_TEXT(ROW(INDIRECT("A1:A"&COUNTA(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7'"))))), "^"&JOIN("$|^",
IF(A2:A="",,MMULT(TRANSPOSE((ROW(A2:A)<=TRANSPOSE(ROW(A2:A)))*(B2:B)),
SIGN(B2:B))+1))&"$"), "♀", )="♀")))
with Holiday list:
=ARRAYFORMULA(FILTER(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7' and not Col1 matches '"&
TEXTJOIN("|", 1, H2:H)&"'"),
IF(REGEXMATCH(TO_TEXT(ROW(INDIRECT("A1:A"&COUNTA(
QUERY(TO_DATE(ROW(INDIRECT(DATEVALUE(C2)&":"&DATEVALUE(C2)+SUM(B2:B)*2))),
"where not dayofweek(Col1) matches '1|7' and not Col1 matches '"&
TEXTJOIN("|", 1, H2:H)&"'"))))), "^"&JOIN("$|^",
IF(A2:A="",,MMULT(TRANSPOSE((ROW(A2:A)<=TRANSPOSE(ROW(A2:A)))*(B2:B)),
SIGN(B2:B))))&"$"), "♀", )="♀"))

AppleScript : Time format change + Calendar events

I'm trying to create a script to log my current time and my finish time
do a specific action them sent an email with this same time variable and create a calendar event with this time variable :
set FinsihDate to (current date) + 10 * hours + 30 * minutes
set startingDate to (current date)
set plistR to {FinsihDate:FinsihDate, starteddate:current date}
tell application "System Events"
set plistf to make new property list file ¬
with properties {name:"~/Desktop/MY_Time.plist"}
set plistf's value to plistR
end tell
## Email
property lastWindowID : missing value
tell application "Mail"
set windowIDs to id of windows
if windowIDs does not contain lastWindowID then
set newMessage to make new outgoing message with properties {subject:"Started early", content:"Hi ..., \n \nI started early today : " & (current date) & ", I will leave at " & FinsihDate & "\n \nKind Regards,\nKevin " & return & return}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {name:"Name", address:"#apple.com"}
end tell
activate
set lastWindowID to id of window 1
else
tell window id lastWindowID
set visible to false
set visible to true
end tell
activate
end if
end tell
set startDate to date (current date)
set endDate to date FinsihDate
tell application "Calendar"
tell (first calendar whose name is "calendar")
make new event at end of events with properties {summary:"Work", start date:startDate, end date:endDate, description:"ITS Fraud Prevention", location:"Apple"}
end tell
end tell
Time format
the time format on the email is " Monday 4 June 2018 at 14:25:57," when I just want 14:25
I tried this :
set myTime to (time string of (current date)) + 10 * hours + 30 * minutes
Result: error "Can’t make \"14:27:02\" into type number." number -1700
from "14:27:02" to number
Calendar
When creating the Calendar event I have this error
error "Can’t get date (date \"Monday 4 June 2018 at 14:29:34\")."
number -1728 from date (date "Monday 4 June 2018 at 14:29:34")
Thanks for itemising the individual errors that you encountered and want fixing. This made is so much easier for me to read this question and decide it was one I wanted to answer, because I don't actually have to test your script at all as I can immediately see what the problems are:
① Your parentheses are in the wrong place. Change this:
set myTime to (time string of (current date)) + 10 * hours + 30 * minutes
to this:
set myTime to time string of ((current date) + 10 * hours + 30 * minutes)
② The error indicates that you've tried to take a variable of type date and then declare it again as type date. AppleScript doesn't like this.
Change these two lines:
set startDate to date (current date)
set endDate to date FinsihDate
to this:
set startDate to (current date)
set endDate to FinsihDate
I haven't tested the rest of the script.
P.S. You misspelled your variable name FinsihDate (which I assume is meant to be FinishDate). However, it's misspelled consistently throughout the script, so it doesn't make any practical difference.

crystal reports month date range for earnings

My client has a report that accepts a date range to get a report showing projected revenue. So, a user would enter a date range of '1/1/2015 to 1/31/2015' and the report should return data only in the range '1/1/2015 to 1/31/2015 grouped by week. I am instead for the week of 12/29/2014 (which 1/1/2015 fall into) and 2/1/2015 (which 1/31/2015 falls into). The report is intended to group by week, but I do not want days on the report that are earlier than the start date parameter or later than the end date parameter.
The sql statement for this report is:
SELECT job.job, job.status, job.customer_po, job.part_number, job.unit_price,
job.price_uofm, delivery.promiseddate, delivery.remaining_quantity, job.build_to_stock, job.description, job.make_quantity, job.pick_quantity, job.shipped_quantity, job.lead_days
FROM dbo.delivery as delivery RIGHT OUTER JOIN db.job as job on delivery.job = job.job
WHERE job.build_to_stock = 0 AND (job.status = 'active' OR job.status = 'hold' OR job.status = 'pending')
The date range is from this code and parameters:
Max – Maximum(?Date Range)
Min – Minimun(?Date Range)
Date Range - "From " & {#Min} & " to " & {#Max}
This is the group expression
Group 2 Name - GroupName ({#Adj Date 2}, "weekly") & " thru " & cdate(GroupName ({#Adj Date 2}, "weekly"))+6
This is the select expression
{#Date} = {?Date Range} and
not {Job.Build_To_Stock} and
{Job.Status} in ["Active", "Hold", "Pending"]
Do you know how I can prevent the "overflow" of dates outside of date range?
Thx
As long as you have date filtering in your record selection formula there will not be any "overflow" outside of that range. If you've got {Record.Date} in Minimum({?DateRange}) to Maximum({?DateRange}), which it sounds like you do, then your report will not contain any records outside of the parameter regardless of how you group them.
Your problem might stem from over-complicating or misinterpreting the grouping. All you need to do is group by {Record.Date} and select "Group by week" in the grouping options... you don't need any complicated formulas to break it out by week. But be aware that the way weeks are referred to is by their starting date. For example, if you had a record with a date of Feb. 19, 2015, that record would fall into the group labeled "Feb. 15, 2015" even if your {?DateRange} parameter was Feb. 18 - Feb. 15.

Data Conversion with DatePart in an MS access select query

I am trying to use DatePart() within a MS Access select query to extract a month and year-- as a number-- from a date which is initially in a string form of
"YYYY-MM-DD HH:NN:SS.0000000"
The initial code written by someone else says:
DatePart("m", date)
DatePart("yyyy", date)
But this was causing a "Data Type, Mismatch in Criteria" error when the query ran, so I attempted to use Cdate() to convert the string to a date type.
DatePart("m", Cdate(date))
DatePart("yyyy", Cdate(date))
However this did not solve the problem. I am wondering if my initial date string is not in a form that Cdate() can convert, or if there is an easier way to extract a partial, numerical date from a date string such as mine.
I am prepared to elaborate much further on the situation in case this question is incomplete, but I did not wish get ahead of myself.
Those extra zeros would be a problem, to strip them, you could say
CDate(Mid(sdate, 1, InStr(sdate, ".") - 1))
Then
DatePart("m", CDate(Mid(sdate, 1, InStr(sdate, ".") - 1)))
However, you may find it more convenient to just refer to the appropriate part of the string:
aYr = Left(sdate,4)
aMnth = Mid(sdate,6,2)
You were right that the fractional seconds prevent CDate from accepting your string. And you could strip away the fractional seconds. But since you ultimately want the year and month, you can ignore all of the time components and just use the date part.
See whether this Immediate window session offers anything useful.
MyString = Format(Now(), "yyyy-mm-dd hh:nn:ss") & ".0000000"
? MyString
2013-02-14 23:38:09.0000000
' if date format is always yyyy-mm-dd,
' give CDate the first 10 characters
? CDate(Left(MyString, 10))
2/14/2013
' year
? DatePart("yyyy", CDate(Left(MyString, 10)))
2013
' or
? Year(Left(MyString, 10))
2013
' month
? DatePart("m", CDate(Left(MyString, 10)))
2
' or
? Month(CDate(Left(MyString, 10)))
2
' if date format can vary slightly, eg yyyy-m-d,
' give CDate everything before the first space
? CDate(Left(MyString, InStr(MyString, Chr(32)) -1))
2/14/2013
? Year(CDate(Left(MyString, InStr(MyString, Chr(32)) -1)))
2013
? Month(CDate(Left(MyString, InStr(MyString, Chr(32)) -1)))
2
You didn't mention what you will do with the year and date numbers after you get them. If you intend to join them together as a string, you could use Format().
? Format(Left(MyString, 10), "yyyymm")
201302