Calculation of the hour and minute coincident times

Source: Internet
Author: User

See a topic like this on the Internet.

How many times a clock's hour, minute, and second hand coincide together in 24 hours of the day? What is the time of the difference? How did you figure that out?

/*1, a day is 86,400 seconds, the dial is a half-day cycle, you only need to calculate a half-day time of 43,200 seconds  2, minute hand and the hour coincide, that is the minute hand and the angle of the hour is the same. 3, Seconds walk a second, the minute hand walk 360°/60 = 6°, the hour walk 360°/432004, noon 12 o'clock, is considered to return to the original point. */declare  @num  intselect  @num  = 0while  @num  <= 43200  /* Number of cycles, seconds left */begin    if (convert (numeric (18,3),360.0/43200*case when  @num  =  43200 then 0 else  @num  end)  = convert (numeric (18,3), ((@num *1.00/60)% *6)  )   /* calculate seconds per second, then the clockwise and minute corresponding walking angles */begin    print  ' current seconds: ' +cast (@Num  as char (6))  +  ' hour and minute hand coincide, time is   '  + cast (@Num  as char (6))  +   '    '                                                          + left (' xx ', 2-len (@Num/3600)) +cast (@Num/3600 as varchar (3))  +   ': '  /* coincident time, hour */                                                          + left (' xx ', 2-len ((@Num/60)%60) +cast ((@Num/60)%60)  as  varchar (3))  +  ': '  /* coincident time, Minute hand */   + left (' xx ', 2-len (@Num%60)) +cast ((@Num%60)  as varchar (4)) When  /* coincident time, the second hand */end    --print cast (@Num  as char (6))  +  '     hour:  '  + cast (CONVERT (numeric (18,2), 360.0/43200* @Num)  as  varchar ()  +  '        minute Hand: ' +cast (CONVERT (numeric (18,2), ((@num * 1.00/60) (%60) *6)  as varchar     select  @Num  =  @Num  + 1end 

The results are as follows:

Current number of seconds: 0 hour and minute hand coincide, time is 0 00:00:00 current seconds: 43200 hour and minute hand coincide, time is 43200 12:00:00

So in 24 hours of the day, the first to walk the calculation once, 12 o'clock noon calculation, 12 o'clock in the morning is also 0 points to calculate once again, then counted three times

This article is from the "360°erp" blog, make sure to keep this source http://360erp.blog.51cto.com/1946797/1695680

Calculation of the hour and minute coincident times

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.