I am trying to convert day-hour-minute-seconds into minute.
Three different examples would be
1 day 02:55:00
12 days 03:40:16
130 days 05:15:40
Thanks
Related
I want to convert a column which contains seconds (i.e 11549404) into days, hours, minutes, seconds
SELECT (myCol || ' second')::interval, 'HH24 hrs MI "minutes" SS "seconds"') AS duration
FROM public.myTable
Which returns the following;
"3208 hrs 10 minutes 04 seconds"
Whats the way to display it as days, hours, minutes seconds
Because some days has 23hours and others 25hours the result is not easy task (it is not possible, because don't know absolute value). interval type is a structure of months, days and seconds. The values are not automatically moved between these fields because mounts has different number of days, days can has different number of seconds. But you can do some normalization - there is a function justify_interval that expects so days has 24 hours every time:
postgres=# select justify_interval('3208 hrs 10 minutes 04 seconds'::interval);
+-------------------------+
| justify_interval |
+-------------------------+
| 4 mons 13 days 16:10:04 |
+-------------------------+
(1 row)
Would it be possible to get same day of week last year using Excel? please below example:
Input: Monday 9 Nov 2015 | Output: 10 Nov 2014
Thanks
Simply subtract 52 full weeks with 7 days = 364 days. So if the date is in A1, the formula =A1-364 will get the date exactly 52 weeks before, which is the same day of week in the year before.
To show that it works even for leap years, try the following:
You see the formula date - 364 (=A2-364, =A3-364, ...) always gets the same day of week a year before. That is because it gets the day minus 52 full weeks (52 * 7 days) before. In leap years it gets a different day but the same day of week.
Try this:
=DATE(YEAR(A1)-1,MONTH(A1),DAY(A1))+WEEKDAY(A1)-WEEKDAY(DATE(YEAR(A1)-1,MONTH(A1),DAY(A1)))
It returns the closest date within a week. A1 is the cell with this year's date.
I'm using SAS 9.3
I need to create a way to sum up by week total, and I have no idea how to do it. So basically I have a year list of dates (left column below) with a total from that date (the right column). Our week goes from Friday to the previous Thursday (e.g. Thursday Oct 17 through Friday the Oct 25th).
An issue I also have is as you see the dates on the left are not completely daily and don't always have a Thursday date before the last Friday date. Would any know a way to add these weeks up - Week 1, Week 2, etc etc ...?
Thanks for any help that can be provided
2013-01-01 3
2013-01-02 8
2013-01-03 8
2013-01-04 10
2013-01-06 1
2013-01-07 10
2013-01-08 14
2013-01-09 12
2013-01-10 8
2013-01-11 9
2013-01-12 1
2013-01-14 12
2013-01-15 8
2013-01-16 5
2013-01-17 15
2013-01-18 7
2013-01-20 1
Trivial way:
data want;
set have;
weekno = ceil((date-'03JAN2013'd)/7);
run;
IE, subtract the first thursday and divide by 7, (so 1/1-1/3 is weekno=0).
INTCK function is also adept at calculating this. The basic structure is
weekno=intck('WEEK.5','04JAN2013'd,date); *the second argument is when you want your first week to start;
WEEK means calculate weeks, # on left side of decimal is multiple week groups (2 week periods is WEEK2.), on right side is shift index (from the default sunday-saturday week).
You could also create a format that contained your weeks, and use that.
How can I make an event occur every year for some selected days, Like starting 45 days then skip 15 days, then select 30 days then skip 30 days, then select 30 days then skip 30 days, then select 30 days then skip 30 days,then select 30 days then skip 30 days,then select 30 days then skip 30 days
RRULE:FREQ=YEARLY;BYYEARDAY=1,2,..,45,61,62,...,90,120,121....
Is this the right procedure?
combination of freq=yearly and byyearday is indeed the way forward, though it does not look ot be the case for you, you could also consider BYWEEKNO.
Here's a bit of fun.
If we peek at the dotnet source code, the following comment can be found at the head of the file TimeSpan.cs:
...while a year can contain 365 or 364 days
Should I be worried?
I don't know what the source code comment refers to, but there are some more exotic calendars where a year only has 364 days, e.g. a leap week calendar:
A leap week calendar is a calendar system with a whole number of weeks every year, and with every year starting on the same weekday. Most leap week calendars are proposed reforms to the civil calendar, but some - such as the ISO week number calendar - are simply conveniences for specific purposes.
The ISO calendar in question is a variation of the Gregorian calendar that is used (mainly) in government and business for fiscal years, as well as in timekeeping. In this system a year (ISO year) has 52 or 53 full weeks (364 or 371 days).
One advantage is the better divisibility. A year with 364 days can be divided into 13 equal months. Other calendars using such a system are according to Wikipedia:
International Fixed Calendar
Pax Calendar
Perhaps they were talking about the maximum day index in a year when the day index starts at zero?
In general, you should not be too worried. There are some years back in time with much less than 364 days! Basically, the crux is the change from Julian to Gregorian calendars, which happened at differing times at differing locales. In the US, the month of interest is Sep 1752,
jlouis#illithid:~$ cal sep 1752
September 1752
Mo Tu We Th Fr Sa Su
1 2 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
since the US was part of the British Empire at that time, see
http://en.wikipedia.org/wiki/Gregorian_calendar#Adoption
for further explanation.
Aside: This is why you should generally not try to do your own date handling. It is pure pain to get all the intricacies correct.
West Samoa crossed the dateline in 2011, skipping December 30th, going from December 29th directly to December 31st.
So technically they had a 364 day year.
Perhaps they meant 365 or 366 days? As far as I know 364 days in a year is not acceptable.
No it can not. Maybe you should worry. Although the number of integer weeks x days per week = 52 x 7 = 364