samjsteffes
New Member
- Joined
- Feb 27, 2018
- Messages
- 16
Hi all,
I have a table column with date values that are imported from another workbook. The original source of the dates is a database system which time-stamps entries, so each item has a time value as well.
Ultimately, I need to extract a count from this table capturing the number of items that fall within a certain date range. I don't care about the exact date & time, only the date that it occurred on. As such, the time component is messing up the accuracy of this count.
I have searched far and wide, and tried a number of different things to try and get the time portion of the value removed. I know that dates are really numbers (i.e. 43100.55676), so theoretically I should be able to perform manipulations as I would other numbers, like int(value), etc. I also know that just changing the format will not change this underlying serial number. I am certain that the values are indeed dates, and not text, as I am able to change the the format between different date variations as well as the see the underlying serial number.
The below code snippet shows some of the different things I have tried, none of which have worked...
At this point, I'm at a loss for what the issue is. All the toggling between formats works fine, but none of the commands to manipulate the value ever do anything. I cannot get the time value removed.
Is it a value issue? Do I need to somehow introduce a 'double' type variable and store the values to it since the serial dates are not true integers/long? Or is the the method I've tried to use? Can you not "bulk" change a range of values this way using a 'with' procedure? I'd rather not step through each value individually, as the range is likely to grow quite large over time and a loop would become quite slow.
I'd really appreciate any help/suggestions. All my searching, stealing other solutions, testing my own have resulted in nothing.
Thanks,
sjs
I have a table column with date values that are imported from another workbook. The original source of the dates is a database system which time-stamps entries, so each item has a time value as well.
Ultimately, I need to extract a count from this table capturing the number of items that fall within a certain date range. I don't care about the exact date & time, only the date that it occurred on. As such, the time component is messing up the accuracy of this count.
I have searched far and wide, and tried a number of different things to try and get the time portion of the value removed. I know that dates are really numbers (i.e. 43100.55676), so theoretically I should be able to perform manipulations as I would other numbers, like int(value), etc. I also know that just changing the format will not change this underlying serial number. I am certain that the values are indeed dates, and not text, as I am able to change the the format between different date variations as well as the see the underlying serial number.
The below code snippet shows some of the different things I have tried, none of which have worked...
Code:
With tbl.ListColumns("Date Reported").DataBodyRange
.NumberFormat = "General"
'.NumberFormat = "dd/mm/yy"
'.Value = DateValue(.Text)
'.Value = .Text
'.Value = DateValue(.Text)
'.Value = CStr(.Value)
'.Value = DateValue(.Value)
.NumberFormat = "General"
'.Value = Int(.Value)
'.Value = WorksheetFunction.Int(.Value)
.Value = VBA.Int(.Value)
.NumberFormat = "dd-mmm-yy"
End With
At this point, I'm at a loss for what the issue is. All the toggling between formats works fine, but none of the commands to manipulate the value ever do anything. I cannot get the time value removed.
Is it a value issue? Do I need to somehow introduce a 'double' type variable and store the values to it since the serial dates are not true integers/long? Or is the the method I've tried to use? Can you not "bulk" change a range of values this way using a 'with' procedure? I'd rather not step through each value individually, as the range is likely to grow quite large over time and a loop would become quite slow.
I'd really appreciate any help/suggestions. All my searching, stealing other solutions, testing my own have resulted in nothing.
Thanks,
sjs