Excel date conversion

W

WKC CCC

Is there a way to convert the excel date number i.e. 34516 into a
datestring: 01-Jul-94

Thanks
 
M

mully

Is there a way to convert the excel date number i.e. 34516 into a
datestring: 01-Jul-94

Thanks

Here's something to keep in mind (if you don't already): A cell in
Excel has a Value property and a Text property. The Value property
returns the underlying data as Excel has stored it. The Text property
returns the formatted text as displayed to the user.

irb(main):010:0> ws.Cells(3, 1).Value
=> "1994/07/01 00:00:00"
irb(main):011:0> ws.Cells(3, 1).Text
=> "01-Jul-94"

So, if the cell is already formatted as you wish, just call the Text
property rather than the Value property.

Hope that helps.

David
 
R

Rob Biedenharn

Is there a way to convert the excel date number i.e. 34516 into a
datestring: 01-Jul-94

Thanks
=> "01-Jul-94"

If that's not quite right, the trick is to find out what date Excel
says is 0 and add that julian date (Date#jd) to the value you want
and then you manipulate the Ruby Data object as needed.

-Rob

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 

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

Members online

Forum statistics

Threads
474,236
Messages
2,571,184
Members
47,820
Latest member
HortenseKo

Latest Threads

Top