Get long value for a date string

  • Thread starter Thread starter jerry chapman
  • Start date Start date
J

jerry chapman

I have a date string of 2/21/2005 1:07:22 PM. When I convert it to Long I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?
 
sStr = "2/21/2005 1:07:22 PM"
v = int(cdate(sStr))
? v
02/21/2005

you could
dim v as Long
 
activecell.numberformat = "mm/dd/yyyy hh:mm:ss"

or put a date value in it

Sub CCC()
Dim dt As Date

dt = DateSerial(2005, 2, 21) + TimeSerial(10, 30, 0)
ActiveCell.Value = dt
ActiveCell.EntireColumn.AutoFit
End Sub
 

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

Similar Threads


Back
Top