423,323 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,323 IT Pros & Developers. It's quick & easy.

how to convert a time to minutes

P: 1
hi

I have a time field in short time format and I want it to convert to minutes and add a time in minutes for it and calculate the total time in hours and minutes. can anyone help me?
May 17 '18 #1
Share this Question
Share on Google+
2 Replies


twinnyfo
Expert Mod 2.5K+
P: 2,536
Hashinimoses,

Welcome to Bytes!

The simplest method I can think of is to use the DateAdd() Function, using “n” as the interval. You can review all teh syntax in this MS Office Article.

Hope this hepps!
May 17 '18 #2

NeoPa
Expert Mod 15k+
P: 30,996
HashiniMoses:
I have a time field in short time format
No. You really don't. You have a Date/Time field (Full stop). How it's formatted when you display it is no part of this question. It's simply confusing you into thinking about it the wrong way.

So, you have a Date/Time value, that presumably has no date component, and you'd like to add x number of minutes to that. You may even desire to show the result as a Time (in Short Time) format.

Of course TwinnyFo is on exactly the right lines. I wanted to try to ensure you not only got an answer, but that you also let go of the wrong-thinking that caused you to be confused in the first place.

So, assuming the variable you start with is datVar, and the number of minutes you want to add is intVar, then you could say :
Expand|Select|Wrap|Line Numbers
  1. datVar = DateAdd("n", intVar, datVar)
To display this as a Short Time (Be careful as this is modulo so won't show correctly if the value exceeds 24 hours.) :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print Format(datVar, "HH:nn")
May 17 '18 #3

Post your reply

Sign in to post your reply or Sign up for a free account.