To convert date and time to milliseconds in Excel, which you need for tasks such as bulkloading certificates in ServiceNow, follow these steps. This process assumes that the timestamp you're starting with represents a local time.
Step 1: Understand the Concept
First, understand that Excel internally represents dates as the number of days since a base date (December 30, 1899, is day 1 for the default starting date system in Excel on Windows). Time is represented as a fractional portion of a day (for example, 12 hours is 0.5 days).
To convert an Excel date and time to milliseconds, you're essentially converting this representation into milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC).
Step 2: Convert Date and Time to Seconds
-
Assuming your date and time are in cell A1, you'll need to calculate the difference in days between your date and the Unix epoch. This means you have to account for the difference between the Excel base date and the Unix epoch. You should subtract the Unix epoch start date from your date:
=A1 - DATE(1970,1,1)
-
Convert the difference in days to seconds (since there are 86,400 seconds in a day):
=(A1 - DATE(1970,1,1)) * 86400
Step 3: Convert Seconds to Milliseconds
To convert the seconds to milliseconds, simply multiply the result by 1,000:
=((A1 - DATE(1970,1,1)) * 86400) * 1000
This formula will give you the number of milliseconds since January 1, 1970, which is the format you're looking for.
Step 4: Notes and Adjustments for Time Zones
-
Time Zone Adjustment: The above calculation assumes the dates/times are in UTC. If your date and time are in another time zone, you may need to adjust this by adding or subtracting the time zone difference in hours, converted to milliseconds. For instance, if you're 5 hours ahead of UTC, subtract 5 hours in milliseconds (-5*3600*1000) from the result.
-
Daylight Saving Time (DST): This calculation does not account for Daylight Saving Time adjustments. If DST affects your timestamps, you'll need to adjust them manually if necessary.
Example
If cell A1 has the date and time 1/1/2021 12:00 PM, and you wish to convert this to milliseconds, the formula in Excel would look like this:
=((A1 - DATE(1970,1,1)) * 86400) * 1000
This converts the given date and time into the number of milliseconds since the Unix epoch (January 1, 1970).
Note: Always ensure your cell format in Excel is set to "General" or "Number" for the cell where you're applying this formula to see the calculated milliseconds correctly.
By following these steps, you'll be able to convert dates and times to milliseconds in Excel, facilitating tasks like preparing data for bulk uploading in systems like ServiceNow.