Timestamps in Stata - time

I am looking to replace a time stamp from 00:00:00 to 23:59:59.
Stata still shows the timestamp as 00:00:00
replace time_out = mdyhms(month(date), day(date), year(date), hh(23), mm(59), ss(59))
format time_out %tc
The storage type is double. It was created by this command:
gen time = clock(ptime, "hm")
format time %tc

I am as yet unable to follow your problem. This toy example shows that changing to show 23:59:59 is perfectly possible.
. clear
. set obs 1
Number of observations (_N) was 0, now 1.
. gen double time = clock("00:00", "hm")
. format time %tc
. list
+--------------------+
| time |
|--------------------|
1. | 01jan1960 00:00:00 |
+--------------------+
. replace time = clock("23:59:59", "hms")
(1 real change made)
. list
+--------------------+
| time |
|--------------------|
1. | 01jan1960 23:59:59 |
+--------------------+

Related

Show daily count and the total count up to that day in Quicksight

I want to create a table analysis in AWS Quicksight that shows the number of new user per day and also the total number of user that has registered up until that day for the specified month.
The following sample table is what I want to achieve in Quicksight.
It shows the daily register count for March:
+-----------+----------------------+----------------------+
| | Daily Register Count | Total Register Count |
+-----------+----------------------+----------------------+
| March 1st | 2 | 42 |
+-----------+----------------------+----------------------+
| March 2nd | 5 | 47 |
+-----------+----------------------+----------------------+
| March 3rd | 3 | 50 |
+-----------+----------------------+----------------------+
| March 4th | 8 | 58 |
+-----------+----------------------+----------------------+
| March 5th | 2 | 60 |
+-----------+----------------------+----------------------+
The "Total Register Count" column above should show the total count of users registered from the beginning up until March 1st, and then for each row it should be incremented with the value from "Daily Register Count"
I'm absolutely scratching my head trying to implement the "Total Register Count". I have found some form of success using runningSum function however I need to be able to filter my dataset by month, and the runningSum function won't count the number outside of the filtered date.
My dataset is very simple, it looks like this:
+----+-------------+---------------+
| id | email | registered_at |
+----+-------------+---------------+
| 1 | aaa#aaa.com | 2020-01-01 |
+----+-------------+---------------+
| 2 | bbb#aaa.com | 2020-01-01 |
+----+-------------+---------------+
| 3 | ccc#aaa.com | 2020-01-03 |
+----+-------------+---------------+
| 4 | abc#aaa.com | 2020-01-04 |
+----+-------------+---------------+
| 5 | def#bbb.com | 2020-02-01 |
+----+-------------+---------------+
I hope someone can help me with this.
Thank you!
I am new to QuickSight but the way I was able to get Total Register Count is by creating a calculated field called count and assigned it the fixed value of 1.
Then I created a second calculated field "Total Register Count" with the following formula
runningSum(sum(count), [{ registered_at} ASC], [])
It sounds as if the CountOver function would work well for you. You'll need to partition your count by the day of the month (using the extract function). Here is a link related to the CountOver function.
https://docs.aws.amazon.com/quicksight/latest/user/countOver-function.html
This is called a Level Aware Aggregation in QuickSight. Here is additional information on that:
https://docs.aws.amazon.com/quicksight/latest/user/level-aware-aggregations.html
Here is information on the extract function:
https://docs.aws.amazon.com/quicksight/latest/user/extract-function.html
If I were to take a stab at your formula, it would look like this:
countover(ID,[extract('DD',registered_at)],PRE_FILTER)
Your table would have the registered_at field as the date.

How to count calculate the remaining time years using Carbon Laravel 5.8

I have a table name user . in user have filed colomn 'date' .
in this colomn field 'date' have data like this
users table
id | name | email | date |
1 | jhon | a#gmail.com | 2021-06-07 |
2 | phil | b#gmail.com | 2020-06-07 |
i want to showed data where 'date' is year is less than 1 year from now.
from this table just show :
2 | phil | b#gmail.com | 2020-06-07 |
because this date is less than 1 year . i am using laravel .
You can use this query to get users which their date field are less than one year from now:
User::query()->where('date', '<', Carbon::now()->subYear())->get();
You want to show users who have "date" that is less than a year from now. You can write a query very easily for that.
$users = User::whereBetween('date', [now(), now()->addYear()])->get();
This will filter down the results who have "date" values between now and a year from now. now is a helper function that returns a carbon date instance.

OBIEE EVALUATE or EVALUATE_AGGR, MAX/MIN Group By

I am trying to summarize the table in OBIEE Analysis Tool (11g) using the EVALUATE or EVALUATE_AGGR Function. I have tried using the traditional MAX and MIN without EVALUATE but due to a bug with the union functionality I am not getting the desired result.
+------------------+------+-----------+----------+
| Loan ID | Year | Month | Balance |
+------------------+------+-----------+----------+
| L201618100000009 | 2021 | March | 232,000 |
| L201618100000009 | 2021 | June | 232,000 |
| L201618100000009 | 2021 | September | 232,000 |
| L201618100000009 | 2021 | December | 232,000 |
+------------------+------+-----------+----------+
EVALUATE_AGGR('MAX(%1 by %2, %3 )', "Loan and Debt Interest"."Loan BOP Amount", "Time"."Year","Loans"."Loan ID" )
I am getting this error: [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: Please have your System Administrator look at the log for more details on this error. (HY000)
Below is a table of what I am expecting but instead because of the UNION the traditional MAX and MIN Functions are not working. (MAX = 928K, MIN = 928K)
+------------------+------+------------------+-------------------+
| Loan ID | Year | (MAX)BOP Balance | (MIN)EOP Balance |
+------------------+------+------------------+-------------------+
| L201618100000009 | 2021 | 232,000 | 232,000 |
+------------------+------+------------------+-------------------+
I'm a bit confused by the recent (re-)increase of questions like "I want to do this SQL in OBI". That's not how the tool works. That's not how it is designed.
a) If you are forced to do UNION requests, then your data model is poor to begin with.
b) You can easily create a level-based measure in the RPD which is tied to the year level of your time hierarchy and then set the aggregation rule to MAX. Same for MIN. That requires a proper data model though.
c) In the analysis you can also create a new calculated column using MAX("Balance" by "Loan ID", "Year") and it will also give you the same result.

Hive query to Extract Date and Hour separately from String

I need to extract Date and hour from the string column in hive.
Table:
select TO_DATE(from_unixtime(UNIX_TIMESTAMP(dates,'dd/MM/yyyy'))) from dates;
output:
0016-01-01
0016-01-01
select TO_DATE(from_unixtime(UNIX_TIMESTAMP(dates,'hh'))) from dates;
output:
1970-01-01
1970-01-01
Please advise how to take date seperately and hour seperately from the table column.
I've change the data sample to something more reasonable
with dates as (select explode(array('1/11/16 3:29','12/7/16 17:19')) as dates)
select from_unixtime(unix_timestamp(dates,'dd/MM/yy HH:mm'),'yyyy-MM-dd') as the_date
,from_unixtime(unix_timestamp(dates,'dd/MM/yy HH:mm'),'H') as H
,from_unixtime(unix_timestamp(dates,'dd/MM/yy HH:mm'),'HH') as HH
from dates
+------------+----+----+
| the_date | h | hh |
+------------+----+----+
| 2016-11-01 | 3 | 03 |
| 2016-07-12 | 17 | 17 |
+------------+----+----+

How to get the file modified date of a file with respect to a particular time zone in Jscript?

I have a file which gets created/modified on a PST machine. But when I am accessing this file from an Indian standard time, the Modified date will be returned according to the current system time zone. (As explained here) Is there any way I can get this date with respect to the time zone provided
var WshShell = Sys.OleObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var objFile = fso.GetFile("c:\\abc.txt");
var date = objFile.DateLastModified + "";
Yes, you do this with the DateDiff function in VBS:
http://www.devguru.com/technologies/vbscript/quickref/datediff.html
DevGuru Info
DateDiff(Interval, Date1, Date2, FirstDayofWeek, FirstWeekofYear)
The DateDiff function calculates the amount of time between two different dates.
There are three mandatory arguments.
Interval
The Interval argument defines the the type of time interval you wish to use to
calculate the time difference.
Only the following settings can be used. You must place the setting inside a
pair of double quotes.
| SETTING | DESCRIPTION |
|:--------|:-------------|
| YYYY | Year |
| Q | Quarter |
| M | Month |
| Y | Day Of Year |
| D | Day |
| W | WeekDay |
| WW | Week Of Year |
| H | Hour |
| N | Minute |
| S | Second |
In javascript you can do it like this:
How to calculate date difference in javascript

Resources