logo
down
shadow

Query between 2 dates hours & minutes


Query between 2 dates hours & minutes

By : user2949139
Date : November 16 2020, 06:23 AM
wish helps you I have a problem with a mysql query, and can't seem to find anything related. , I would suggest subtracting 30 minutes for the hour comparison:
code :
select count(*), YEAR(date), MONTH(date), DAY(date)
from table
where YEAR(date) = 2014 AND
      HOUR(date - interval 30 minute) between 08 and 17
group by YEAR(date), MONTH(date), DAY(date);
select count(*), YEAR(date), MONTH(date), DAY(date)
from table
where YEAR(date) = 2014 AND
      TIME(date) BETWEEN TIME('08:30:00') and TIME('18:30:00')
group by YEAR(date), MONTH(date), DAY(date);


Share : facebook icon twitter icon
DIFF from two dates and get hours and minutes

DIFF from two dates and get hours and minutes


By : ross franey
Date : March 29 2020, 07:55 AM
wish helps you , From the PHP manual:
code :
$hours = $interval->h + ($interval->d*24);
print "{$hours} hours ".$interval->format('%i minutes');
How to get hours and minutes by subtracting two dates?

How to get hours and minutes by subtracting two dates?


By : DevShepherd
Date : March 29 2020, 07:55 AM
seems to work fine Try this you will get atleast idea how to calculate time difference between two dates.
code :
   SELECT floor(((date1-date2)*24*60*60)/3600)
            || ' HOURS ' ||
             floor((((date1-date2)*24*60*60) -
           floor(((date1-date2)*24*60*60)/3600)*3600)/60)
            || ' MINUTES ' ||
            round((((date1-date2)*24*60*60) -
             floor(((date1-date2)*24*60*60)/3600)*3600 -
            (floor((((date1-date2)*24*60*60) -
           floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60) ))
          || ' SECS ' time_difference
     FROM dates;

    TIME_DIFFERENCE
    --------------------------------------------------------------------------------
    24 HOURS 0 MINUTES 0 SECS
    1 HOURS 0 MINUTES 0 SECS
    0 HOURS 1 MINUTES 0 SECS
How to display Hours and Minutes between two dates

How to display Hours and Minutes between two dates


By : learner heart
Date : March 29 2020, 07:55 AM
it helps some times I am having a table consists of to datetime columns "StartTime" and "CompleteTime". Initially completeTime column will be NULL untill the process is completed. And now my requirement is to display hours and minutes as shown Below , Try this
code :
DECLARE @STARTDATE DATETIME = '2016-03-31 04:59:11.253'
DECLARE @ENDDATE DATETIME = GETUTCDATE()

SELECT CONVERT(VARCHAR(10),DATEDIFF(MINUTE, @STARTDATE, @ENDDATE)/60)+':'+CONVERT(VARCHAR(10),DATEDIFF(MINUTE, @STARTDATE, @ENDDATE)%60)+' hr' AS DIFF
Diff
0:52 hr
72:56 hr
iterating between dates, hours and minutes

iterating between dates, hours and minutes


By : Andrea Marie Parks
Date : March 29 2020, 07:55 AM
I hope this helps you . I am trying to iterate between 2 dates received as inputs and print every 5 minutes (during working hours) , Maybe you're overcomplicating; take a look into this:
code :
var startDate = new DateTime(2018, 1, 1);
var endDate = new DateTime(2018, 3, 1);
while ((startDate = startDate.AddMinutes(5)) < endDate)
{
    if (startDate.Hour < 8 || startDate.Hour > 17 ||
        startDate.DayOfWeek == DayOfWeek.Saturday || 
        startDate.DayOfWeek == DayOfWeek.Sunday)
        continue;

    Console.WriteLine("{0:ddd, MMM dd, yyyy HH:mm}", startDate);
}
Get difference between 2 dates in hours minutes and seconds beyond 24 hours fails

Get difference between 2 dates in hours minutes and seconds beyond 24 hours fails


By : user3003421
Date : March 29 2020, 07:55 AM
seems to work fine You can access the days property of the $diff object, and multiply it by 24 (as there are 24 hours in a day), then add the H format (to get the remaining hours) before concatenating the minutes and seconds.
The H value will never exceed 24, as the hours in a day will never be above that.
code :
$from = "2019-05-20 23:59";
$to = "2019-05-27 00:00";

$expiry_time = new DateTime($to);
$current_date = new DateTime($from);
$diff = $expiry_time->diff($current_date);
return ($diff->days*24 + $diff->format("%H")).$diff->format(':%I:%S'); // 144:01:00
Related Posts Related Posts :
  • select the records with the highest amount
  • Changing Mysql golbal variable
  • How to create Effective Indexing on MySQL
  • `require': Incorrect MySQL client library version
  • How to save a FirstName of a Person efficiently without duplicate entries
  • Can I store my own sql query by mysql special function and execute stored query later?
  • MySQL comma separated field query
  • Why does the same exact query produce 2 different MySQL explain results?
  • Suppress warning output in bash
  • Doctrine "on update CURRENT_TIMESTAMP" annotation (Symfony2)
  • Designing "Friend" relationships across two mysql tables
  • Importing sql file using phpmyadmin in EasyPHP
  • Easy PHP and mysql ..php cannot see database on local pc (all works on server)
  • MySQL join optimization - bypassing filesort
  • How to Select record with the maximum value in a GROUP BY?
  • MySQL Innodb Full text Proximity Search Gives Horrible Performance
  • MySQL best approach for db normalising, relationships and foreign keys
  • How to update one table based on the count value of another table while matching ids?
  • MAMP Pro 5.1.1-terminates MySQL when quitting
  • SQL - Get date of most votes cast
  • "Fuzzier" search in mysql
  • Tracing mysqld Using SystemTap
  • SELECT + INSERT + Query Cache = MySQL lock up
  • SQL vs. NoSQL for medium complexity search systems
  • SQL Error when creating table
  • Is it possible to write a query to compare rows to other rows in same table?
  • Display all duplicate records based multiple columns
  • summing time column in mysql
  • InnoDB: Cannot open table
  • Why is IN() considered O(logN) operation?
  • Can a deadlock occur on commit?
  • Is there a fast way to do a '%phrase%' search in any DB?
  • Is using an IN over a huge data set a good idea?
  • How can I know if a table is already arranged in ascending order in MySQL?
  • MySQL - Designing database for a simple game
  • Why am I getting "Host '192.168.1.220' is not allowed to connect to this MySQL server"?
  • what type of password hash? possible mysql hash?
  • MySQL - Using a date range vs functions
  • Using IS NULL and COALESCE in OrderBy Doctrine Querybuilder
  • How to merge MySQL columns into one column if there are empty values in the table?
  • Cardinality Confusion
  • Renaming column multiple ids in SELECT
  • Group all from and to messages per user
  • How to handled the null values in WHERE IN condition in mysql
  • Is it okay to update primary key field to shift a record to the top?
  • Stop query through pdo
  • How to check whether particular value in field in MySQL exists
  • Execute a statement for every table in a database
  • insertion 74G data into mysql table cost more then 2 days, how to improve insert performance
  • Where can I see the differents "Hibernate Console Configurations" in Eclipse
  • MySql | relational database vs non relational database in terms of Performance
  • Exporting mysql database using mysqldump including procedures
  • Trigger MySQL not working
  • How do I update values for individual rows quickly?
  • MySQL join query with multiple where condition
  • MySQL stored procedure is not working
  • MySQL - Order By exact match at the end
  • Select max date or null date from same table MySQL
  • Best solution workaround for needing a mysql event on insert?
  • MySQL select several columns of several tables at the same time without using JOIN
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org