| View previous topic :: View next topic |
| Author |
Message |
mieslep Newbie

Joined: 10 Mar 2006 Posts: 2
|
Posted: Wed Mar 15, 2006 12:52 pm Post subject: DATEVALUE and converting a string to a date |
|
|
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 |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Wed Mar 15, 2006 2:12 pm Post subject: |
|
|
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 |
|
 |
Dale Super User

Joined: 21 Feb 2005 Posts: 1440 Location: Australia
|
Posted: Wed Mar 15, 2006 2:35 pm Post subject: |
|
|
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 |
|
 |
denmarks OOo Enthusiast


Joined: 01 Mar 2006 Posts: 125 Location: Chico, CA
|
Posted: Wed Mar 15, 2006 2:52 pm Post subject: |
|
|
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 |
|
 |
mieslep Newbie

Joined: 10 Mar 2006 Posts: 2
|
Posted: Thu Mar 16, 2006 2:19 am Post subject: |
|
|
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
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 |
|
 |
|