Convert date and time to unix timestamps

Alfie101

New Member
Joined
Jan 29, 2016
Messages
19
Hi,
I maybe overlooking clues I can see on the internet but I am still having trouble converting date and time (day-month-year-mins, sample below) into unix timestamps. Would be most grateful for help please.
Alfie101
20/4/2017 30
20/4/2017 32
20/4/2017 39
20/4/2017 40
20/4/2017 44
20/4/2017 51
20/4/2017 59

<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Do the minutes increment up after 59 to 60 (60 being 1:00 AM) and so on?

If that's the case I believe this UDF will do it:

Code:
Function UnixTime(r As String) As Long
Dim d, dv
r = Replace(r, " ", "/")
d = Split(r, "/")
dv = DateValue(d(1) & " " & d(0) & " " & d(2)) + TimeSerial(0, d(3), 0)
UnixTime = (dv - DateSerial(1970, 1, 1)) * 86400
End Function


Excel 2010
AB
120/4/2017 301492648200
220/4/2017 321492648320
320/4/2017 391492648740
420/4/2017 401492648800
520/4/2017 441492649040
620/4/2017 511492649460
720/4/2017 591492649940
Sheet1
Cell Formulas
RangeFormula
B1=unixtime(A1)
B2=unixtime(A2)
B3=unixtime(A3)
B4=unixtime(A4)
B5=unixtime(A5)
B6=unixtime(A6)
B7=unixtime(A7)
 
Last edited:
Upvote 0
Do the minutes increment up after 59 to 60 (60 being 1:00 AM) and so on?

If that's the case I believe this UDF will do it:

Code:
Function UnixTime(r As String) As Long
Dim d, dv
r = Replace(r, " ", "/")
d = Split(r, "/")
dv = DateValue(d(1) & " " & d(0) & " " & d(2)) + TimeSerial(0, d(3), 0)
UnixTime = (dv - DateSerial(1970, 1, 1)) * 86400
End Function

Excel 2010
AB
120/4/2017 301492648200
220/4/2017 321492648320
320/4/2017 391492648740
420/4/2017 401492648800
520/4/2017 441492649040
620/4/2017 511492649460
720/4/2017 591492649940

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B1=unixtime(A1)
B2=unixtime(A2)
B3=unixtime(A3)
B4=unixtime(A4)
B5=unixtime(A5)
B6=unixtime(A6)
B7=unixtime(A7)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Hi Scott,
Thank you lots. I shall try it in the next days and let you know.
Again thanks, regards,
Alfie101
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

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