Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2025, 01:22 AM
MishkaGrizzly MishkaGrizzly is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 11 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2021
Novice
Convert whole number to hours and minutes and remove 0 hours or minutes
 
Join Date: Nov 2025
Posts: 4
MishkaGrizzly is on a distinguished road
Default Convert whole number to hours and minutes and remove 0 hours or minutes

I would appreciate any help.



I have a merged field as a whole number for example, 60, 90, 45, 30.

I would like to convert that to hours and minutes, so the output would look something like this.

1 hr
1 hr 30 min
45 min
30 min

Notice that if its 0 hours or 0 min then I don't need to output anything.

Many thanks in advance
Reply With Quote
  #2  
Old 11-05-2025, 04:01 AM
macropod's Avatar
macropod macropod is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 10 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,501
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use a field construction like:
{=INT({MERGEFIELD Minutes}/60) \# "0' hr '"}{=MOD({MERGEFIELD Minutes},60) \# "0' min'"}
or
{=INT(«Minutes»/60) \# "0' hr '"}{=MOD(«Minutes»,60) \# "0' min'"}
where 'Minutes' is your datafield name.

NOTE: The field brace pairs (i.e. '{ }') for the above field code examples are created in the mailmerge main document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from here. Nor is it practicable (for the most part) to add them via the standard Word dialogues. Likewise, the chevrons (i.e. '« »') - are part of the actual mergefields, inserted via the 'Insert Merge Field' dropdown (i.e. you can't type them or copy & paste them from here). The spaces shown in the field constructions are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-05-2025, 04:17 AM
MishkaGrizzly MishkaGrizzly is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 11 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2021
Novice
Convert whole number to hours and minutes and remove 0 hours or minutes
 
Join Date: Nov 2025
Posts: 4
MishkaGrizzly is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You could use a field construction like:
{=INT({MERGEFIELD Minutes}/60) \# "0' hr '"}{=MOD({MERGEFIELD Minutes},60) \# "0' min'"}
or
{=INT(«Minutes»/60) \# "0' hr '"}{=MOD(«Minutes»,60) \# "0' min'"}
where 'Minutes' is your datafield name.

NOTE: The field brace pairs (i.e. '{ }') for the above field code examples are created in the mailmerge main document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from here. Nor is it practicable (for the most part) to add them via the standard Word dialogues. Likewise, the chevrons (i.e. '« »') - are part of the actual mergefields, inserted via the 'Insert Merge Field' dropdown (i.e. you can't type them or copy & paste them from here). The spaces shown in the field constructions are all required.
Thank you for your reply.

I have tried this but the output I get is something like that

0 hr 30 min

I am trying to remove the 0 hr or 0 min if there is any, so the end result will be just

30 min
or
2 hr
or
1 hr 15 min

Thanks,
Reply With Quote
  #4  
Old 11-05-2025, 07:36 AM
MishkaGrizzly MishkaGrizzly is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 11 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2021
Novice
Convert whole number to hours and minutes and remove 0 hours or minutes
 
Join Date: Nov 2025
Posts: 4
MishkaGrizzly is on a distinguished road
Default

I believe I solved my own question!

{IF {=INT(«Minutes»/60)} > 0 {=INT(«Minutes»/60) \# "0' hr '"}}
{IF {=MOD(«Minutes»,60)} > 0 {=MOD(«Minutes»,60) \# "0' min'"}}

Might not be best way, but it seems to work
Reply With Quote
  #5  
Old 11-05-2025, 12:43 PM
macropod's Avatar
macropod macropod is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 10 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,501
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Change the:
{=INT({MERGEFIELD Minutes}/60) \# "0' hr '"}
or
{=INT(«Minutes»/60) \# "0' hr '"}
to:
{=INT({MERGEFIELD Minutes}/60) \# "0' hr ';;"}
or
{=INT(«Minutes»/60) \# "0' hr ';;"}

Likewise, change the:
{=MOD({MERGEFIELD Minutes},60) \# "0' min'"}
or
{=MOD(«Minutes»,60) \# "0' min'"}
to:
{=MOD({MERGEFIELD Minutes},60) \# "0' min';;"}
or
{=MOD(«Minutes»,60) \# "0' min';;"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 11-05-2025, 01:33 PM
MishkaGrizzly MishkaGrizzly is offline Convert whole number to hours and minutes and remove 0 hours or minutes Windows 11 Convert whole number to hours and minutes and remove 0 hours or minutes Office 2021
Novice
Convert whole number to hours and minutes and remove 0 hours or minutes
 
Join Date: Nov 2025
Posts: 4
MishkaGrizzly is on a distinguished road
Default

That worked perfect, thank you so much!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countdown of Days, Hours, Minutes and Seconds Chris Waller PowerPoint 3 01-31-2022 03:22 AM
Calculating Total Hours & Minutes Worked aaghd72 Excel 2 04-13-2019 03:32 AM
Outlook 2013 gives 12 decimals after the minutes/hours Curious Outlook 0 11-23-2017 08:38 AM
Convert whole number to hours and minutes and remove 0 hours or minutes Trouble with absolute values and hours/minutes and formulas dglazer Excel 2 07-28-2015 01:42 AM
How to transform hours into minutes in mail merge ppochelon Mail Merge 1 09-29-2013 07:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft