OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

DATEVALUE and converting a string to a date

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
mieslep
Newbie
Newbie


Joined: 10 Mar 2006
Posts: 2

PostPosted: Wed Mar 15, 2006 12:52 pm    Post subject: DATEVALUE and converting a string to a date Reply with quote

Hello,

I have a string output from the Unix 'date' utility that looks like this:

Mon Mar 13 15:48:33 CST 2006

Say this is in cell A1.

I want to get this into a date value, but this isn't working.

MID(A1;5;6)&RIGHT(A1;5)

It gives me a string that looks right ('Mar 13 2006') BUT with DATEVALUE this ends up evaluating as 30Dec1899. Subsequent calculations on this cell confirm that it is being treated by Calc as 30Dec1899.

Any ideas?
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Mar 15, 2006 2:12 pm    Post subject: Reply with quote

Easiest way would be to provide another output format (according to your standard locale format) from your date command.

I get an ISO8601 format output with:
Code:

echo $(date "+%Y-%m-%d")

echo $(date --iso)


Is this possible?
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
Dale
Super User
Super User


Joined: 21 Feb 2005
Posts: 1440
Location: Australia

PostPosted: Wed Mar 15, 2006 2:35 pm    Post subject: Reply with quote

It looks like DATVALUE is not recognising "Mar 13 2006" as a date. This will probably depend on your locale setting. It is certainly the case on my setup using Australian/English date format. You could try:
    =MID(A1;9;2)&" "&MID(A1;5;3)&RIGHT(A1;5)
which will return "13 Mar 2006" - or maybe change your locale to one that uses US date format.
_________________
Dale
To err is human, but to destroy your slippers in the process takes a real son of a bitch: Me!

OOo documentation from the source
http://documentation.openoffice.org
Guides, FAQ, How Tos


Last edited by Dale on Wed Mar 15, 2006 3:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
denmarks
OOo Enthusiast
OOo Enthusiast


Joined: 01 Mar 2006
Posts: 125
Location: Chico, CA

PostPosted: Wed Mar 15, 2006 2:52 pm    Post subject: Reply with quote

Try using =DATEVALUE(MID(A1;5;6)&RIGHT(A1;5)).
It worked for me. You can also try =DATEVALUE(MID(A1;5;6)&","&RIGHT(A1;5)).

This is my spreadsheet with the first formula.
Mon Mar 13 15:48:33 CST 2006
03/13/2006
_________________
Dennis Marks
Back to top
View user's profile Send private message Visit poster's website
mieslep
Newbie
Newbie


Joined: 10 Mar 2006
Posts: 2

PostPosted: Thu Mar 16, 2006 2:19 am    Post subject: Reply with quote

I'm on v2.0.2 and am in the Ireland/English locale. If I input the string "13 Mar 2006" or the string "13 March 2006" it is recognized as a date and automatically converted to my default date format.

denmarks, neither of your suggestions worked. Sorry.

probe1, you're right except that I can't control the code that is outputting the date Sad

dale, I could swear this was one of my permutations, but perhaps not. The formula

=DATEVALUE(MID(A1;9;2)&" "&MID(A1;5;3)&RIGHT(A1;5))

Did the job, thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group