Create a time stamp from a date and vv

  • Thread starter Thread starter hhalle
  • Start date Start date
H

hhalle

Help!
I want to write a udf in vba as function d2tstamp() and a function
tspam2d() which does just that.
I have it working combining data from different cells and letting excel
do the calculation but cannot get it to work in vba

Date to Timestamp:
Date: 12-12-2005
X = 38698.00 serial value for 12-12-2005
Y = 25569.00 serial value for 1-1-1970

Calculation: (X - Y) * 24 * 60 * 60 = 1134345600

Timestamp to Date:
Calculation: (Timestamp / 24 * 60 *60) + Y = 12-12-2005

All this looks perfect but when I put it in a vba code and run it it
doesn't want to work.
Does anybody have a sample code for me? Two sample codes?

:mad: :confused: :eek:
 
Hi,

When I say it wont work is that I gat either a #VALUE! error of a
#NUMBER! error

When taking it step by step and including msgboxes to show the
intermediary results those are OK but the final returns the error.

Thanks for reading

Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top