convert dates serial

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Convert dates to Serial

Convert dates to Serial

resolvedResolved · Low Priority · Version 2007

Edited on Fri 10 Jun 2011, 11:17

Pedro has attended:
Excel VBA Intro Intermediate course

Convert dates to Serial

Hello,

The Question:
How can I convert a date stored as string into a serial format?


Why I need it:
I found that to update the values of a pivot according to a date using VBA the date have to be in serial format.

I use this code to do that:

Workbooks(Name).Sheets("Zara").Range("G28").Value = PT.GetPivotData("Sum of Average", "Company", 1, "YearMonth", pivot_date).Value



I got the date as a string in a cell and I tried to conver it into serial using the Format function with 'c' but it didn't work

pivot_date=Format(str_date, c)


There is other way to convert String Into Serial(date)?

Thanks,
Pedro F. Pardo

RE: Convert dates to Serial

Hi Pedro, thanks for your query. There is another way, you have to parse the text string and then use the DateSerial function. More information here...:

http://www.cpearson.com/excel/datetime.htm

...and here:

http://www.cpearson.com/excel/DateTimeVBA.htm

Hope this helps,

Anthony

 

Training courses

 

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Use Paint Brush to Format More than one Cell

To copy a format to many cells or ranges

1. Select the cell with the format that you want to copy

2. Double-click on the paint brush

When you move to the cell where you want to paste the format you will notice that a paint brush follows the cursor.

Paste the format to all the cells or ranges you need to format.

When finished go back to the paint brush on the tool bar and single click on it to deactivate the function.

View all Excel hints and tips


Server loaded in 0.08 secs.