Identify and name a timestamp for specific data entry points - postgresql

I have a situation where I'm trying to look at changes in data based on timestamp of user entry (or 'created on').
The data highlights planning for delivery of goods, users have the ability to 're-plan' their dates of entry.
What I need to do is look at the timestamp for each 're-planning' date and be able to tell if the date of planning was changed within 7 days of delivery. For example
Data line XXY was planned for delivery on the 29th of August, 2017...but was changed, ON the 27th, to the 30th....this is a flag...
Like wise XXZ was planned for the 30th but changed to September 15th on the 29th...also a flag. Both were changed within 7 days of their previous 'delivery' date. Does this make sense and is there a simple way to do this?

Related

Powerapps Filter Collection By Today's Date

Good day all,
I am trying to filter todays result in SQL table to a collection in powerapps. The column "dt" represents the column in sql of datetime type.
This is my powerapps filter:
ClearCollect(myCollectionName, Filter(myDatasource, Text(dt,"dd/mm/yyyy") = Text(Now(),"dd/mm/yyyy" )));
Seems like the collection is still empty even there is data for today in sql. May I know if my approach is the correct way in filtering?
Short answer: the data is likely being changed based on the client time zone. To fix it, you can update it by applying the time zone offset to the data from the SQL table, something along the lines of:
ClearCollect(
myCollectionName,
Filter(
myDatasource,
Text(DateAdd(dt, TimeZoneOffset(dt), Minutes), "dd/mm/yyyy") =
Text(Now(), "dd/mm/yyyy")))
Long(er) answer: the datetime type in SQL Server represents an absolute value of date and time. For example, the value '2021-12-23 09:30:00' represents 9:30 in the morning of the 23rd day of December, 2021 - at any part of the world. The date/time type in Power Apps, however, represents a point in time, typically referring to the local time where the app is being executed (or created). For example, if I selected that value and I'm in the US Pacific Time Zone (UTC-08:00), that would represent the same value as if someone in London (UTC+00:00) selected 2021-12-23 17:30:00. Since the two types represent different concepts, we may have mismatches like you are facing. To fix this, we can either use a type in SQL Server that has the same semantics as Power Apps (for example, 'datetimeoffset'), or adjust the time when it is being transferred between SQL and Power Apps.
The blog post at https://powerapps.microsoft.com/en-us/blog/working-with-datetime-values-in-sql explains in more details how to work with date/time values in SQL and Power Apps.

ical/ics: Better way to do a daily 3-month reminder every year

I am trying to setup a daily 3-month reminder that would occur every year; that is a reminder that occurs daily starting August 1st and ending October 31st, every year. I poured over the RFC and crafted a RRULE that I am sure will work, but I am curious: is there a better way?
RRULE:FREQ=YEARLY;BYMONTH=8,9,10;BYMONTHDAY=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
This ICS is going to be imported into Google calendar.
Yes there is a simpler solution. Just create a rule to recur DAILY but only in months 8, 9 and 10:
FREQ=DAILY;BYMONTH=8,9,10
Your start date should be August 1st.
See the results as generated by recurrence-expansion-service.appspot.com.

Mailchimp Conditional Merge tags using a date field not working

This is not about the API. This is about using Mailchimp and setting conditional merge fields in the backend of Mailchimp when building a campaign. So this question is about how Mailchimp works rather than about integrating Mailchimp via an API or something similar.
(You're still here? Great! :-)
I'm trying to use a date field to show conditional content.
I have 3 people in my test mailing list, one with birthday 1/1/1960, one with 1/1/1970 and one with 1/1/1980.
I've set up an email with three conditional block so that each recipient should get the right piece of text in his mail. It looks like this.
The format I'm using is:
*|IF:BIRTHDATE>1/1/1970|*
Some text for people with a birthdate greater than 1 jan 1970
*|END:IF|*
*|IF:BIRTHDATE=1/1/1970|*
Some text for people with a birthdate equal to 1 jan 1970
*|END:IF|*
*|IF:BIRTHDATE<1/1/1970|*
Some text for people with a birthdate smaller than 1 jan 1970
*|END:IF|*
I've taken the date of the 1st of jan (1/1) to avoid possible conflicts with US and EU date notations to rule that out of the debugging process.
However, eacht recipient receives the last of the three texts when sending the test mailing, meaning that all three, regardless of their birthdate somehow match the last condition *|IF:BIRTHDATE<1/1/1970|*
This is strange since I've deliberately taken the middel birthdate to rule this out.
The date notation in the list of recipients matches the exact dat notation that I'm using in the conditions.
Does anyone have any idea how this should be done with dates in Mailchimp? I can't find any iformation on that on either Mailchimp or anywhere else on the net.
You have to use the format 'YYYY-MM-DD'.
I was struggling with this, too, but I have the below working:
*|IF:VALIDUNTIL=2016-12-31|*
Vaild Member
*|ELSE:|*
Expired Member
*|END:IF|*
Don't know if this is a recent change, but Roger's answer only works for exact date comparison.
*|IF:JOINED=2017-01-31|*
You joined ON jan 31st
*|ELSE:|*
You joined literally any other date
*|END:IF|*
If you want to use comparisons, they work the same as any other merge tag (But only in the YYYY-MM-DD format)
*|IF:JOINED>2017-01-31|*
You joined after January 31st 2017
*|ELSE:|*
You joined before January 31st 2017
*|END:IF|*

How to handle dates in neo4j

I'm an historian of medieval history and I'm trying to code networks between kings, dukes, popes etc. over a period of time of about 50 years (from 1220 to 1270) in medieval Germany. As I'm not a specialist for graph-databases I'm looking for a possibility to handle dates and date-ranges.
Are there any possibilities to handle over a date-range to an edge so that the edges, which represents a relationship, disappears after e.g. 3 years?
Are there any possibility to ask for relationships who have their date-tag in a date-range?
The common way to deal with dates in Neo4j is storing them either as a string representation or as millis since epoch (aka msec passed since Jan 01 1970).
The first approach makes the graph more easily readable the latter allows you to do math e.g. calculate deltas.
In your case I'd store two properties called validFrom and validTo on the relationships. You queries need to make sure you're looking for the correct time interval.
E.g. to find the king(s) in charge of France from Jan 01 1220 to Dec 31st 1221 you do:
MATCH (c:Country{name:'France'})-[r:HAS_KING]->(king)
WHERE r.validFrom >= -23667123600000 and r.validTo <=-23604051600000
RETURN king, r.validFrom, r.validTo
addendum
Since Neo4j 3.0 there's the APOC library which provides couple of functions for converting timestamps to/from human readable date strings.
You can also store the dates in their number representation in the following format: YYYYMMDD
In your case 12200101 would be Jan 1st 1220 and 12701231 would be Dec 31st 1270.
It's a useful and readable format and you can perform range searches like:
MATCH (h:HistoricEvent)
WHERE h.date >= 12200101 AND h.date < 12701231
RETURN h
It would also let you order by dates, if you need to.
As of Neo4J 3.4, the system handles duration and dates, see the official documentation. See more examples here.
An example related to the original question: Retrieve the historical events that happened in the last 30 days from now :
WITH duration({days: 30}) AS duration
MATCH (h:HistoricEvent)
WHERE date() - duration < date(h.date)
RETURN h
Another option for dates that keeps the number of nodes/properties you create fairly low is a linked list years (earliest year of interest - latest year), one of months (1-12), and one of dates in a month (1-31). Then every "event" in your graph can be connected to a year, month, and day. This way you don't have to create a new node for every new combination of a year month and day. You just have a single set of months, one of days, and one year. I scale the numbers to make manipulating them easier like so
Years are yyyy*10000
Months are mm*100
Date are dd
so if you run a query such as
match (event)-[:happened]->(t:time)
with event,sum(t.num) as date
return event.name,date
order by date
You will get a list of all events in chronological order with dates like Janurary 17th, 1904 appearing as 19040117 (yyyymmdd format)
Further, since these are linked lists where, for example,
...-(t0:time {num:19040000})-[:precedes]->(t1:time {num:19050000})-...
ordering is built into the nodes too.
This is, so far, how I have liked to do my event dating

sqlite3: retrieving data based on month and year from local database in iphone

In my application I have to store data month wise and year wise. So for this, I have to store the data along with date into database.
My requirement is how to store in terms of date and how to retrieve data with group by month and year. In my app I am showing a table of years and months, based on selected month and year. I have to show the data in a dashboard.
My problem is in storing and retrieving date data types.
Use the following syntax
SELECT * FROM DATABASE WHERE REQUIREDDATEFIELD LIKE '%2011-01%';
2011 is supposed to be the year
01 is supposed to be the month
DATABASE is supposed to be your mysql database name
REQUIREDDATEFIELD is supposed to be the field you are hoping to sort from month and year.
like '%2011-01%' is supposed to be meaning, all the records containing 2011-01 in the given field. It could be in the beginning or the end or in the middle of a large text, so having % in both the beginning and end of the search criteria is a good habit.
You just select either for a specific month or year or month and year. Or if you want all, you use GROUP BY.
I know this answer is quite vague and generic, but that's because your question is vague. You probably need to be more specific. Explain not only what you want to do, but what you have tried, and in which way that didn't work.