Access Round down not working 100%

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

What im trying to do is round down to the nearest half half hour

so if createddatetime is say 03/07/2020 00:05:27 then the period should fall in 00:00:00
if its 00:31:00 then it should fall in 00:30:00
if its 01:01:00 then 01:00:00, if 01:59:57 then 01:30

Hope this makes sense as occasionally the formula below is catagorising into 00:05 and 00:25etc

This is my Formula in VBA

CreatedPeriod = FORMAT(CStr(ROUND(([CreatedDateTime] - INT([CreatedDateTime]))*48,0)/48), ""hh:nn"")
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Thank you
Would i use 0.5 as my significance for my example?
 
Upvote 0
FORMAT(CStr(Floor(([CreatedDateTime] - INT([CreatedDateTime])),0.5) ""hh:nn"")

is that right
 
Upvote 0
Or is the right syntax

FORMAT(CStr(Floor(([CreatedDateTime] - INT([CreatedDateTime])),30/1440 ""hh:nn"")

Thank you and appreciated
 
Upvote 0
haven't used access for years, so i don't have a great answer. 0.5 would be 12 hours in excel, as 1 = a day. in excel you have the option of TIME(00,30,00), i couldn't guess how to manipulate the values for your need
 
Upvote 0
Thank you hopefully someone can confirm the right syntax to use in access
 
Upvote 0
I tend to start with Google?

That led me to this link and that produced pretty much what you are after I believe?

HTH
 
Upvote 0
thank you
Surely i can use Moleys suggestion but still unsure what the right syntax is
 
Upvote 0
In the other thread it says this but this doesn’t always rounddown
TimeSerial(Hour([mytime]),(Minute([mytime])\30)*30,0)

my created date time has a date and time in there so my aim was to take the time from
That and put into a category by rounding down to nearest half hour

i thought it would be a lot simpler to do like in excel using the Floor Function

any help with my example would really be appreciated

thank you
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,849
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top