Converting 12-hour time to 24-hour time using Field Calculator

Converting 12-hour time to 24-hour time using Field Calculator

Does anyone know how to convert string time formats in ArcMap v10.2 from 12-hour to 24-hour using a simple query in the Field Calculator? i.e. NO Python, NO editing in Excel, NO changing my Windows PC settings, etc…

This is a successful calculation I used (which I found on a discontinued forum) to convert my dates from MM/DD/YYYY to YYYY/MM/DD:

year([DateFld]) & "/" & Month([DateFld]) & "/" & Day([DateFld])

Perhaps there is some sort of modification that I could make to the above calculation that would change my times to 24-hour? I've searched for an answer everywhere and played around with it without any luck, but I would like for the times to be in h:mm:ss format.

Forgot to mention that this is a regular shapefile, not part of a GDB.

There is actually an ArcGIS tool specifically for this task: Convert Time Field. You don't even need to use the Field Calculator. Just specify the format of the source date/time field and your desired output format and the tool will create a new field and populate it with the converted values. It can be used for converting dates, times, or a combination of both.

Python program to convert a 24 hour format to 12 hour format

Given a string in a 24 hour format the program outputs a 12 hour format. The rules are:

  • The output format must be 'hh:mm a.m.' if it represents before midday and 'hh:mm p.m.' after midday
  • When the hour is less than 10:00 you should not write a 0 before the hour, example: '9:05 a.m.'

12:30 → 12:30 p.m.
09:00 → 9:00 a.m.
23:15 → 11:15 p.m.

To determine your annual salary, take your hourly wage and multiply it by the number of paid hours you work per week and then by the number of paid weeks you work per year.

Yearly salary = hourly wage × hours per week × weeks per year

For guidance, a standard working week for a full-time employee is around 40 hours. Note that if you take two weeks of unpaid leave per year, your number of weeks will be 50, rather than 52.

Example annual salary calculation

As an example, if you make $15 per hour and are paid for working 40 hours per week for 52 weeks per year, your annual salary (pre-tax) will be 15 × 40 × 52 = $31,200. On a side-note, if you want to work out your hours and earnings for a given week, give the time card calculator a try.

Using this formula, we can calculate the following annual incomes from basic hourly pay. It's important to remember that these figures are pre-tax.

Hourly pay to annual salary
Hourly pay Weekly pay (40 hrs) Monthly pay (avg) Annual salary (52 weeks)
$10 per hour$400$1,733.33$20,800
$11 per hour$440$1,906.67$22,880
$12 per hour$480$2,080.00$24,960
$13 per hour$520$2,253.33$27,040
$14 per hour$560$2,426.67$29,120
$15 per hour$600$2,600.00$31,200
$16 per hour$640$2,773.33$33,280
$17 per hour$680$2,946.67$35,360
$18 per hour$720$3,120.00$37,440
$19 per hour$760$3,293.33$39,520
$20 per hour$800$3,466.67$41,600
$21 per hour$840$3,640.00$43,680
$22 per hour$880$3,813.33$45,760
$23 per hour$920$3,986.67$47,840
$24 per hour$960$4,160.00$49,920
$25 per hour$1,000$4,333.33$52,000
$26 per hour$1,040$4,506.67$54,080
$27 per hour$1,080$4,680.00$56,160
$28 per hour$1,120$4,853.33$58,240
$29 per hour$1,160$5,026.67$60,320
$30 per hour$1,200$5,200.00$62,400

Converting 12-hour time to 24-hour time using Field Calculator - Geographic Information Systems

Advantages and disadvantages of 12-hour shifts

Longer shifts have become increasingly popular with workers in 24/7 operations. However, some managers still have reservations due to concerns about safety and productivity. Let's explore each group's perspective. After that, we'll discuss a couple of scheduling issues related to 12-hour shifts.

Shiftworker Opinions
In surveys of over 20 thousand shift workers, 74% said they would like to work more hours a day in order to get more days off each week. With each of our larger clients, we show the workforce several different schedule options that satisfy the client&rsquos business coverage requirements. By educating employees about the various possibilities, they are able to make more informed choices from the schedule alternatives. The options we show employees typically include one or more 8-hour, combined 8 & 12-hour, and 12-hour schedules. Roughly 90% of the time, the highest-rated schedules consist of 12-hour shifts.

Reasons for the popularity of 12-hour shifts among shift workers:

  • More days off . In a 24/7 operation with 8-hour shifts, there are 91 scheduled days off per year. With 12-hour shifts, there are twice as many (182 days off per year). These numbers are based on 4-crew schedules with level coverage requirements. Benefits of the extra days off include reduced commuting expenses, less need to take paid time off for doctor appointments, school meetings, or personal activities, and improved morale as a result of better work/life balance.
  • More weekends off . The maximum possible number of full weekends off with 8-hour shifts is 13 per year. The most common schedules that accomplish this require employees to work 7 days in row. 8-hour schedules that feature 5 or 6 days of work in a row only provide 5-6 weekends off per year. The maximum possible number of full weekends off with 12-hour shifts is 26 per year. Unlike the 8-hour schedules, this can be achieved under a variety of configurations with a maximum of 4 consecutive days of work.
  • Longer breaks . In contrast with most 8-hour shift schedules that provide a maximum of 4 days off, 12-hour schedules can provide up to 8 consecutive days off. And, by strategically taking 48 hours of vacation, the break can be extended to as much as 2 full weeks. Longer breaks mean more time to recover from the sleep debt incurred while working the longer shifts.
  • Other benefits. This includes things like the elimination of double shifts to cover absences and the elimination of afternoon shifts (an unpopular shift for employees with families).

While longer shifts are certainly popular nationwide, they are not the unanimous preference of all shift workers. Employees who are older, have childcare concerns, are going to school, have second jobs, or participate in other non-work activities on work days often prefer 8-hour or combined 8 & 12-hour shift schedules. Other disadvantages of 12-hour shifts are:

  • Long hours. Not only is 12 hours a long time to work, but if you add in commute time and meal breaks, this can be a very long day. This leaves little time for anything but eating and sleeping.
  • Irregular pay weeks. Half the work weeks will be 48 hours and half will be 36 hours. Depending on the schedule selected, these may not occur in alternating weeks. For example, with one on-off pattern there are four consecutive 48-hour weeks followed by four consecutive 36-hour weeks. Unless the organization is able to balance the paychecks, employees will find this tough to budget for.
  • Absence coverage. Instead of holding someone over to cover an absence, the organization now must call someone in from a scheduled day off. If there is a high absence rate, this can defeat the primary advantage of the longer shifts, namely more days off.

Management Opinions
Managers are sometimes reluctant to adopt 12-hour shifts because they believe alertness and productivity decline after 8 hours of work. The more you read on the subject, the more confused you get. Some researchers have concluded that the longer shifts were detrimental to productivity and safety others say that things got better after workers changed to 12-hour shifts. A good place to review the research is a report by the Police Foundation called The Shift Length Experiment. Here's a link to the report:

We believe that the differing conclusions stem from comparing dissimilar situations. Researchers may have compared one group on an 8-hour fixed shift schedule with another group on a 12-hour rotating shift schedule. They didn't factor in different schedule variables, such as the on-off work pattern, the amount of overtime, shift start times, and so on. They also didn't consider worker characteristics or the work environment. Problems they attribute to working longer shifts most likely are the result of these other factors in combination with the shift length.

Based our experience with organizations that have adopted longer shifts, we have not found problems as long as the schedule is well designed, with sufficient time off and reasonable limits on the number of consecutive days worked. Our surveys show that over a period of time, shift workers on 12-hour shifts actually get more sleep than those on 8-hour shifts. They may get less sleep on the days they work the 12-hour shifts, but they get twice as many days off. Since everyone sleeps longer on their days off, the average sleep with 12s is greater than the average sleep with 8s.

Average Hours of Sleep Over a Four-Week Period: 8-Hour vs. 12-Hour Shifts

Schedule Shift Length Days of Work Hours of Sleep Days Off Hours of Sleep Average
Days only 8 hours 21 6.5 7 7.5 6.8
12 hours 14 6.3 14 7.5 6.9
Nights only 8 hours 21 6.1 7 7.5 6.5
12 hours 14 6.2 14 7.5 6.9
Rotating shifts 8 hours 21 6.5 7 7.5 6.7
12 hours 14 6.3 14 7.5 6.9

As a result, 12-hour shifts actually have several benefits for management:

  • Better productivity. In addition to less sleep debt, workers only have two shift turnovers a day instead of three. Since shift transitions are a common source of slow-downs and errors, productivity tends to be improved with fewer of them. Accountability also seems to rise with 12s. Problems are fixed right away rather than passing them on to the next shift. And projects are more likely to be finished by the same crew that started them.
  • Reduced absenteeism. One reason is that workers have more time off during the week to attend to personal obligations. Another reason is that they don't want to take a full 12 hours off for a one-hour appointment. Finally, they tend to be more accountable because they know someone has to be called in from a day off to fill the vacancy.
  • Lower turnover. Since employees like the longer shifts, they are less likely to seek other jobs or occupations.
  • Employee attention. On the days they work 12-hour shifts, employees tend to avoid social events, excessive alcohol consumption, or physically exhausting activities. This means they are more attentive and dedicated to the work.

There are some jobs that are not suited to longer shifts (such as tedious detail inspections). Jobs with exposure to extreme heat, loud noises, toxins or heavy physical labor may simply be too much to endure for more than 8-hours. Other disadvantages for management include:

  • Long hours. Even though employees get more sleep over time, their alertness and attention span may not last a full 12 hours. Sitting at a terminal or work station for 12 hours straight can increase the likelihood of ergonomic problems. Jobs may have to be redesigned to compensate for this.
  • Absence management. It becomes harder to cover absences since you can't rely on holding someone over. Larger companies can purchase software that makes it easier to select and contact overtime candidates. Smaller companies that can't afford the software may find that supervisors are spending a large percentage of their time trying to fill the vacancies.
  • Second jobs. Employees may find it easier to take on a second job. Instead of spending their time off recuperating, they will be working elsewhere. This could affect their alertness and dedication.
  • Long breaks. Employees may love them, but things can change at work while they are gone. Employees will take longer to get back up to speed and to learn new procedures and directions. Managers can alleviate this by avoiding 12-hour work patterns that have long breaks.
  • Communication. Since employees work only half as many days, there are fewer opportunities for personal interaction with management and the support staff. Holding information meetings often require employees to stay longer than 12 hours which means lack of attention and increased risk of accidents during the commute afterward.
  • Training. Unless time for training is built into the schedule, formal training must be done on the employees' days off. If training is voluntary, attendance may decline as a result.

Scheduling Considerations
Once you've decided that 12-hour shifts would be a good choice, it's tempting to search the Internet for "free 12 hour shift schedule examples." Eventually you'll find samples of popular patterns such as the 2-3-2 (aka Pitman or Panama), super long break (aka DuPont), 3-on-3-off, 4-on-4-off, etc. Before you do that, please keep the following points in mind:

We can help you find the best 12-hour shift schedule for your resources and requirements:

Online Age Calculator

Do you want to know exactly how old you are to the nearest minute?

Have you been alive for more than a billion seconds?

Do you know how many days old you are?

Our online age calculator will tell you all you need to know.

We hope you have found our 24 Hour Clock Conversion Sheets useful. please feel free to give us feedback below.

How to Print or Save these sheets

Need help with printing or saving?
Follow these 3 easy steps to get your worksheets printed out perfectly!

How to Print or Save these sheets

Need help with printing or saving?
Follow these 3 easy steps to get your worksheets printed out perfectly!

The Math Salamanders hope you enjoy using these free printable Math worksheets and all our other Math games and resources.

We welcome any comments about our site or worksheets on the Facebook comments box at the bottom of every page.

Converting 12-hour time to 24-hour time using Field Calculator - Geographic Information Systems

  1. Right-click [Call Time] on the Rows shelf and select the first More > Hour

Option 3: Shift all date & time values to the same date
  1. Select Analysis > Create Calculated Field
  2. In the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "Call Time w/o Date"
    2. In the formula field, create a calculation similar to the following:
      DATEADD('day', DATEDIFF('day', [Call Time], TODAY()), [Call Time])
    Option 4: Append all times to the same date to create a date field
    1. Select Analysis > Create Calculated Field
    2. In the Calculated Field dialog box that opens, do the following, and then click OK:
      1. Name the calculated field. In this example, the calculated field is named "Start Date"
      2. In the formula field, create a calculation similar to the following:
        DATETIME( "1/1/19 " + [Start Time] )
        Note that there is a space after the date, this will help Tableau Desktop correctly read the date and time.

      Additional Information

      Tableau requires times in Date & Time fields to be associated with a date. This allows for chronological sorting across days.

      In order to graph times from different days on top of each other, the times must be shifted to the same day. If the original data does not include a date, then a Date & Time field can be created with an arbitrary date.

      A 24 hour day can have two midnights: one at the start of the day, and the other at the very end. In the 24 hour time system, the times are written as 00:00 and 24:00. This sign in Switzerland gives the general idea:

      For practical reasons, though, clocks can’t show both 00:00 and 24:00. Most 24 hour analog clocks have settled on showing 0 or 00 to start the day. A few show 24. I think this is because it emphasizes the type of clock you’re looking at.

      In the 12 hour time system, midnight is usually written as 12 AM, and midday (noon) as 12 PM. People find this confusing because 12 AM is before 1 AM yet after 11 PM – the sequence 11 PM – 12 AM – 1 AM confuses because the suffix changes an hour before the value switches back to 1. The period of time between 11 AM and 12 AM is either 11 or 13 hours, but not 1, which you might expect. It’s also confusing that “12 AM” appears to mean 12 hours before noon (“ante meridiem”) but “1 AM” means 1 hour after starting counting from midnight, before noon.

      - Guide Authored by Corin B. Arenas, published on October 24, 2019

      Most people haven’t heard of modular arithmetic or mod outside of math class.

      However, if you’ve ever estimated lunch for 10 people, and found that there’s a lot of food leftover, you’re actually dealing with a mod problem. People use modular arithmetic all the time, especially with anything involving remainders, time and calendar schedules.

      In this section, you’ll learn about modulo, its basic operation, and its uses in real life.

      What is Modulo?

      Modular arithmetic, sometimes called clock arithmetic, is a calculation that involves a number that resets itself to zero each time a whole number greater than 1, which is the mod, is reached. An example of this is the 24-hour digital clock, which resets itself to 0 at midnight.

      In mathematics, the modulo is the remainder or the number that’s left after a number is divided by another value. Modulo is also referred to as ‘mod.’

      The standard format for mod is:
      a mod n
      Where a is the value that is divided by n.

      For example, you’re calculating 15 mod 4. When you divide 15 by 4, there’s a remainder.
      15 / 4 = 3.75

      Instead of its decimal form (0.75), when you use the mod function in a calculator, the remainder is a whole number. For this example, 15 / 4 = remainder 3, which is also 15 = (4 * 3) + 3. Here’s how to calculate it manually:

      15 mod 4
      15 – 4 = 11
      11 – 4 = 7
      7 – 4 = 3

      Calculating Mod with a Negative Number

      One might presume the mod function generates the same values as positive numbers when one number is negative. This is actually not the case.

      For instance, if you have 340 mod 60, the remainder is 40.
      But if you have -340 mod 60, the remainder is 20.

      Why does this happen? explains, with a positive number like 340, the multiple subtracted is less than the absolute value, which results in 40.

      340 mod 60
      340 – 60 = 280
      280 – 60 = 220
      220 – 60 = 160
      160 – 60 = 100
      100 – 60 = 40

      But with -340, we subtract a number with a greater absolute value, so the mod function generates a positive value. The resulting remainder is also smaller compared to when both numbers are positive.

      Here’s how to solve mod with a negative number:
      a mod n is a/n = r (remainder)
      Therefore, a mod n = a – r * n

      Take note: When we input a/b in a calculator, we take the decimal part of the generated value, and round it up to the next integer. Let’s do it with the example below:

      -340 mod 60
      -340/60 = 5.6, when we take the decimal part, it becomes the integer -6
      = -340 -(-6) * 60
      = -340 -(-360)
      = 20

      To help you visualize, the number line below shows the difference in value.

      Who Created Modular Arithmetic?

      According to Britannica, the concept of modular arithmetic has been used by ancient civilizations such as the Indians and Chinese. An example is the Chinese book Master Sun’s Mathematical Manual, which dates back from 300 AD.

      Moreover, modular arithmetic was used to solve astronomical and seasonal calculations which were problems associated with natural and man-made cycles.

      Carl Friedrich Gauss and the Number Theory

      In Western mathematics, German mathematician and physicist Carl Friedrich Gauss did the first systematic study of modular arithmetic. Gauss is regarded as one of the most influential figures in modern mathematics.

      In his early 20s in 1801, he published Disquisitiones Arithmeticae, which laid the foundation for today’s number theory and showed the first proof of the law of quadratic reciprocity.

      In the number theory, scholars analyze the properties of natural numbers, which are whole numbers like -1, -2, 0, 1, 2, and so on. Their objective is to discover unexpected mathematical patterns and interactions between natural numbers.

      Britannica notes that in modular arithmetic, where mod is N, all the numbers (0, 1, 2, …, N − 1,) are known as residues modulo N. The residues are added by finding the arithmetic sum of the numbers, and the mod is subtracted from the sum as many times as possible. This diminishes the sum to a number M, which is between 0 and N – 1.

      In his book, Gauss included a notation with the symbol ≡, which is read as “is congruent to.” Instead of the usual = symbol, the three horizontal line segments both signify equality and definition.

      For instance, if we add the sum of 2, 4, 3 and 7, the sum is congruent to 6 (mod 10). That’s 16 ≡ (mod 10). This means 16 divided by 10 leaves a remainder of 6. Likewise, 16 – 10 = 6.

      Another example, 13 ≡ 1 (mod 12). This means 13 divided by 12 leaves a remainder of 1. Likewise, 13 – 12 = 1.

      What are Real-World Uses for Mod?

      For practical applications, mod is especially useful for dealing with time.

      Since we have 24 hours in a day, it makes sense to refer to time in a 24-hour fashion. This is the principle behind the military time system, beginning at midnight with 0000 hours, and ending the hour at 11PM with 2300 hours.

      Instead of saying 9 o’clock PM, they say 2100 hours. The military uses this to coordinate with bases and other personnel located in different time zones. Moreover, all pilots (commercial or otherwise) use the 24-hour clock to avoid confusion while traveling between time zones.

      To set a standard, pilots and the military use the Greenwich Mean Time (GMT) which they also call Zulu time (Z). For instance, when pilots report that a plane will reach a base at 2100Z, it means it will arrive at 9PM GMT.

      How is this connected with modulo? For people staying in one time zone, it’s more important to tell time by separating night and day. This is why the 12-hour standard time uses modulo.

      Instead of saying 1600 hours, we just say 4 o’clock. The 12-hour standard time uses mod 12 so that 1600 hours becomes 4 o’clock.

      When we make appointments, it’s generally understood people mean 4 in the afternoon. Unless specified otherwise, a 4am meeting is absurd, unless you work at night and have online meetings with clients from other time zones.

      Organizing Books, Bank Info, and Housing Loan Rates

      Mod is useful for organizing large information. Books are tracked using modular arithmetic to calculate checksums for international standard book numbers (ISBN). In 2007, a 13-digit ISBN number system (which was previously 10) was introduced to help manufacturers identify a large volume of books.

      The same principle is also used by banks to identify errors on international bank account numbers (IBAN) when they track transactions from other countries.

      When it comes to housing loans, mod is used to reset calculations for a new period. For instance, a 5/6 adjustable rate mortgage (ARM) resets its interest rates periodically every 6 months. Mod is used to adjust the rates accordingly.

      Cryptography and Computer-Generated Art

      Modular arithmetic has other applications in the field of cryptography, art and graphics design.

      For many years, artists have been using mathematical shapes based on formulas to create designs. Today, the same concept is applied to computer graphics, as well as sculptures and modern paintings.

      In cryptography, codes are written to protect secret data. Cryptographers use mod in the Diffie-Hellman Key Exchange in setting up SSL connections to encrypt web traffic.

      Encryption is important because it allows users to safeguard information. That’s why your personal emails, credit card number, and other personal details should be encrypted whenever you send information on the internet.

      The Bottom Line

      Mod is a mathematical function that allows us to measure the remainder in a sum. We use this fundamental concept whenever we tell time.

      The concept of modular arithmetic has been used by ancient Chinese and Indians for centuries. But it was introduced into Western mathematics by German scientist Carl Friedrich Gauss, who also developed the basis for the number theory.

      Real-world uses for mod include organizing ISBN and bank information, resetting ARM rates, computer graphics design, and cryptography which helps protect private data.

      Midnight has another problem: there is nothing to tell us "is this the beginning or ending of the day".

      Imagine your friends say they are leaving for holiday at "midnight" on 12th March, what day should you arrive to say goodbye?

      Do you get there on the 11th (assuming they leave at the very start of the 12th), or the 12th (assuming they leave at the end of the 12th)?

      which the railroads, airlines and military actually do.

      So, when you see something like "offer ends midnight October 15th" tell them to use one minute before or after so there is no confusion!

      Footnote on "Meridiem" vs "Meridian"

      Should "AM" be "ante meridiem" or "ante meridian" (likewise for PM)?

      The official (according to an American, Australian and British dictionary I checked), and most common spelling for AM is "ante meridiem" which is a Latin phrase. I recommend that spelling!

      But people sometimes use the phrase "ante meridian" (a "meridian" in this case refers to an imaginary line in the sky when the sun is at its highest point).

      3 Answers 3

      The most logical way to transform hour is into two variables that swing back and forth out of sink. Imagine the position of the end of the hour hand of a 24-hour clock. The x position swings back and forth out of sink with the y position. For a 24-hour clock you can accomplish this with x=sin(2pi*hour/24) , y=cos(2pi*hour/24) .

      You need both variables or the proper movement through time is lost. This is due to the fact that the derivative of either sin or cos changes in time where as the (x,y) position varies smoothly as it travels around the unit circle.

      Finally, consider whether it is worthwhile to add a third feature to trace linear time, which can be constructed my hours (or minutes or seconds) from the start of the first record or a Unix time stamp or something similar. These three features then provide proxies for both the cyclic and linear progression of time e.g. you can pull out cyclic phenomenon like sleep cycles in people's movement and also linear growth like population vs. time.

      Adding some relevant example code that I generated for another answer:

      Example of if being accomplished:

      You can just barely see that there are some after midnight times included with the before midnight green cluster. Now lets reduce the number of clusters and show that before and after midnight can be connected in a single cluster in more detail:

      See how the blue cluster contains times that are from before and after midnight that are clustered together in the same cluster.

      Watch the video: How to Calculate 24 Hour Time Grade 5 Nelson