• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to format numeric value to Date and Time

mhghg

Member
Hello Guys,
I got very small issue in my vb script. I have a sql query to get data from sql server
using ADO recordset. After copy and paste data into the active sheet. I have the numeric value for Date/Time column.
How do you change numeric value to the format [6/8/2016 2:39:00 PM],which is the format of current data using vba?
Thanks
Macy
 
Hi ,

Adding a line of code such as :

ActiveCell.NumberFormat = "dd\/mm\/yyyy hh:mm:ss AM/PM"

will change the cell format of the active cell to what you want.

Instead of ActiveCell , you can use a fixed range , such as :

Range("A5:A52").NumberFormat = "dd\/mm\/yyyy hh:mm:ss AM/PM"

Narayan
 
Back
Top