Questions tagged [hour]

457 questions
14
votes
2 answers

Extracting date, hour and minute from Instant.now() generated date

I have this code that generates a date and time, ZoneId z = ZoneId.of( "Africa/Nairobi" ); Instant instant = Instant.now(); ZonedDateTime zdt = instant.atZone(z); return zdt.toString(); //2018-03-19T09:03:22.858+03:00[Africa/Nairobi] Is…
Gandalf
  • 1
  • 29
  • 94
  • 165
13
votes
5 answers

Fastest way to extract hour from time (HH:MM)

Wish fastPOSIXct works - but not working in this case. Here is my time data (which does not have dates) - and I need to get the hours-part from them. times <- c("9:46","11:06", "14:17", "19:53", "0:03", "3:56") Here is the wrong output from…
Gopalakrishna Palem
  • 1,705
  • 1
  • 20
  • 34
10
votes
2 answers

extract hour from timestamp with python

I have a dataframe df_energy2 df_energy2.info() RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null…
Poisson
  • 1,543
  • 6
  • 23
  • 34
9
votes
2 answers

How can I extract just the hour of a timestamp using standardSQL

How can I extract just the hour of a timestamp using standardSQL. I've tried everything and no function works. The problem is that I have to extract the time from a column and this column is in the following format:2018-07-09T02:40:23.652Z If I just…
Layla Comparin
  • 217
  • 1
  • 2
  • 8
9
votes
1 answer

How to know if Locale is using 12 or 24 hours format?

I'm trying to know if, from the Locale, I have to use the 24 or the 12 format. I found this: if (android.text.format.DateFormat.is24HourFormat(getApplicationContext())) But this returns a boolean according to the system, not to the Locale. This…
Virthuss
  • 3,142
  • 1
  • 21
  • 39
9
votes
6 answers

Java Calendar Hour of Day Returning 12 Hour Format

In the Java docs, Calendar.HOUR is supposed to return the hour in the 12 hour format, and Calendar.HOUR_OF_DAY is supposed to return the hour in the 24 hour format, but both of these are returning in the 12 hour format. My Code: Calendar rightNow =…
Brian Leishman
  • 8,155
  • 11
  • 57
  • 93
7
votes
4 answers

How to calculate hour:minutes from total minutes?

For example i have 525 minutes, if we will divide it by 60 the result will be 8.75 But 1 hour have only 60 minutes not 75 How can i calculate the exact hour:minutes from total minutes?
Valoda
  • 335
  • 1
  • 5
  • 21
7
votes
2 answers

How to round to nearest hour and minutes by incremment in JavaScript without using moment.js?

Expected Result Round Off Time : 15 min Given Time 10:00 => Rounded to: 10:00 Given Time 10:13 => Rounded to: 10:15 Given Time 10:15 => Rounded to: 10:15 Given Time 10:16 => Rounded to: 10:30 Given Time 16:00 => Rounded to: 16:00 Given Time 16:12 =>…
siva
  • 593
  • 3
  • 8
  • 19
7
votes
2 answers

Calculate only working hours between two dates excluding weekends in Java

I need help please, How can I calculate business hours between two dates? For example we have two dates; 01/01/2017 10:00 and 04/01/2017 15:00. And we have working hours 09:30 to 17:30 (8 hours) on weekdays. How can I calculate working hours and…
MIDO LOUAFI
  • 71
  • 1
  • 2
7
votes
3 answers

Convert 12-hour format to 24-hour format in C#

How to convert 12-hour format to 24-hour format in DateTime format. I already tried to convert the DateTime to string (24-hour format) and convert it back to Datetime format but it is not working.
wmazizi
  • 99
  • 1
  • 1
  • 6
7
votes
2 answers

How can I select hourly counts from a table, including missing hours?

I'm looking to gather counts by hour. But not every hour is represented in my table. To make sure the data always includes empty hours, I built an hour table that has hours in datetime from 2000-2037. I figure I can LEFT JOIN data tables to this…
Ryan
  • 14,682
  • 32
  • 106
  • 179
7
votes
3 answers

Oracle PLSQL truncate datetime to specific hours

I have an Oracle PLSQL code generating a list of datetime stamps and I would like to truncate them to the specific hours of 7am and 7pm rather than the beginning of the day. For example: 01/03/2013 0700 becomes 01/03/2013 0700 01/03/2013…
user2793907
  • 131
  • 2
  • 2
  • 4
6
votes
2 answers

Calculate number of weeks , days and hours from milliseconds

There were many similar questions around but none addressed this calculation. Using javascript i it is easy to find the number of milliseconds diff b/w 2 dates for ex: var mil = Math.floor(new Date("1/1/2012") - new Date("1/7/2012")) mil is…
Deeptechtons
  • 10,945
  • 27
  • 96
  • 178
6
votes
2 answers

How to remove leading zero from time(hours)

I want to have the hour from 1-9 without the leading zero, but the minutes with the zero while also adding 15 minutes to the time. Right now, when I input 1 and 46 i get 02:01, and i want to get 2:01 Scanner scan = new Scanner(System.in); int hour =…
MickeyMoise
  • 259
  • 2
  • 13
6
votes
1 answer

Converting date into hours

I want to find time difference between two date and then compare the difference time in hours. Something like this, StartTime = 2011-03-10 15:45:48 EndTime = 2011-03-10 18:04:00 And then find the difference as, timeDifference = abs(StartTime -…
Rohita Khatiwada
  • 2,835
  • 9
  • 40
  • 52
1
2
3
30 31