PDA

View Full Version : Solved: Date/time format change with macro...



NateW
10-18-2007, 10:29 AM
Hi, Folks...

I'm trying to populate a schedule by taking specific information from another spreadsheet.

This is no problem, but where I'm stumped is that I'm trying to take date information from the source worksheet, which is in this format:

8/7/2007 8:00:00 AM

and put it into the target location as

8/7/2007

I have a feeling that "mid" won't work, due to the fact that the number of characters in the date changes from the mimimum above, to something like:

12/12/2007

and everything in between...

So, I'm guessing I can do a format change to the date, to make it date only, instead of date/time, but I'm not sure how to do that.

Any ideas?? Thanks so much in advance for any help!!

unmarkedhelicopter
10-18-2007, 10:38 AM
range("A1").value = datevalue(your value)
range("A1").numberformat = "d/m/yyyy"

NateW
10-18-2007, 10:55 AM
Thanks!! I can work with that... Cheers!

Bob Phillips
10-18-2007, 11:04 AM
If those cells are real date/time cells, you can use INT as the date is the integer portion of the number value.

Cyberdude
10-20-2007, 03:45 PM
It isn't clear to me what the format of your data is, but here's two ideas assumming the value is in cell A1:
If the input value is text, like 12/12/2007 8:30 PM, then use
=LEFT(A1, SEARCH(" ", A1))
If the input is in "date" format, then use
=INT(A1)