Click here to Skip to main content
15,891,204 members
Articles / VBA

Timestamp Converter for Excel (VBA)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
9 Sep 2022CPOL4 min read 5.8K   89   2  
Converts a column of timestamps with a format "hh:mm:ss.000" (or similar) to a column of cumlative decimal values of time in units of sec, min, hrs or days.
Many spreadsheets or data files include a timestamp somewhere in every new row (or record) of data. While timestamps are convienent (human readable), they do not lend themselves to data manipulation or calculations primarily because of the 60:1 ratio used for seconds/minutes and minutes/hours. This ratio can make converting from timestamps to any decimal unit of time (seconds for example) complicated and error prone. Even after working out a way to convert a set of timestamps, that same technique could fail with data from some other source because formats vary. Timestamps can be stored as values or as text using a 12hr format or a 24hr format. The attached file contains an Excel macro (VBA) that will reliably convert timestamps (text or values) to decimal values from either a 12 hr format or a 24hr. The macro inserts a new column immediately to the right of the timestamps and populates it with decimal based time values in units of sec, min, hrs or days. Aside from the new time va

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Seagate
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions