LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-19-2009, 06:09 PM   #1
joegumbo
Member
 
Registered: Sep 2006
Distribution: MX-16 Modified using TDE
Posts: 239

Rep: Reputation: 32
Absolute date


Hi,

I'm using Slackware 12.2, but I don't think this is a distro-specific question.

Is there a way I can display a date as an absolute date either by using bash or some other utility/app in Linux?

For example...

Convert month/day/year to 56778

Thanks,
-Joe

Edit...
Btw, I've already tried with the manpages for date and I don't seem to be able to find anything there to convert to absolute date. I've also crossposted to the OpenOffice Forum about this. This is for an assignment that is due Tuesday and of course, the textbook is written with MS Office in mind.

Last edited by joegumbo; 04-19-2009 at 06:22 PM. Reason: typo
 
Old 04-19-2009, 06:35 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
[QUOTE=joegumbo;3514453
Convert month/day/year to 56778
[/QUOTE]

WHAT IS an absolute date?

The example you give doesn't ring a bell, what is the mapping function you use? Number of days since ... ? As far as I can see it is not the number of seconds since 1970-01-01.

I can't imagine it is something date cannot do, but I admit, date's man page is not the best one to describe all the options.

Since you are referring to OpenOffice, is this something which can be done in Bash, or is it something you need in Calc?

jlinkels
 
Old 04-19-2009, 06:48 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
Per the LQ Rules, please do not post homework assignments. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.

That said and I find the subject of time very interesting but what do you mean by absolute date and how does this pertain to MS Office?
 
Old 04-19-2009, 07:12 PM   #4
joegumbo
Member
 
Registered: Sep 2006
Distribution: MX-16 Modified using TDE
Posts: 239

Original Poster
Rep: Reputation: 32
The question is not what you imagine it to be. I'm to convert a specific date to an absolute date. I'm not posting that date. I'm asking how to do this with non-MS software because I don't have MS Office installed. The textbook is explicit in how to do it with MS Excel.

I know how to do this in Excel...
In Excel, enter the date into a cell. Format > Cells... Format Cells > Number Tab > Number. It is then converted to an Absolute Date. If I had MS Office installed, I'd be done.

Do you consider it cheating to ask about other methods using FOSS? If I had wanted to cheat, I wouldn't have posted that this is an assignment and no one would be the wiser.

Absolute Dates are used to do such things as calculate how many days are between two dates by converting them to numbers without regard as to how many days are in each month, leap years, etc. and then doing calculations. For instance, how masny days between 2 dates centuries apart?

I'm not asking anyone to do the assignment; I'm asking for a non-MS procedure to follow to do the conversion.



Edit...
Never mind....
I figured it out on my own.

In Calc,
Enter a date into a cell. 11/22/2299 , e.g.
Format
Cells...
Make sure the "Numbers" tab is clicked
and under Format, click on -1234
Under Category, Change from Date by clicking on Number.
The date will be converted to a number that can be used for calculations. 146059 , e.g.

11/22/2299 = day number 146059


Lets say you wanted to know how many days there are between today's date and 4/19/1000. Just convert and find the difference.

Last edited by joegumbo; 04-19-2009 at 08:04 PM.
 
Old 04-19-2009, 08:09 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If that's like Julian date then also have a look at Perderabo's datecalc (unix.com)?
 
Old 04-19-2009, 08:13 PM   #6
joegumbo
Member
 
Registered: Sep 2006
Distribution: MX-16 Modified using TDE
Posts: 239

Original Poster
Rep: Reputation: 32
That's excellent!!!

Thank you unSpawn!

-Joe
 
Old 04-19-2009, 08:17 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Heh, don't thank me, thank Perderabo.
 
Old 04-19-2009, 08:29 PM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
This can be about a homework assignment, but I don't believe the question is to solve the assigment, but rather how to use tools. This is not a typical Linux question because there doesn't seem to be a textbook solution.

For any time calculations I recommend to use time stamps, or the number of seconds after 1970-01-01 00:00.

It is a weird format anyway, day 2 is 1900-01-01. I suppose somewhere there goes something wrong with leap centuries. (2000 was a leap year because it can be divided thru 400)

Anyway, 1970-01-01 has day number 25569 according to Calc.
1901-12-31 yields 731 in Calc
Difference 24838

If you use the date function:ts=$(date -d '1901-12-31' +%s)
$ts=-2146003200
-2146003200 / 24 / 3600 = -24838

Pretty close uh?

Unfortunately date doesn't accept dates earlier than 1901-12-31 so I can't prove that according to this calculation 1901-01-01 gets day number 2 but you get the idea.

Furthermore, date accepts offsets, e.g. to calculate a new date using an offset:

Code:
date -d '1971-12-31 + 365 days' +%Y-%m-%d
1972-12-30
Remember that bash doesn't do any floating point arithmetic, you can feed the result of date into dc so this becomes the complete function:
Code:
echo "$(date -d '1980-01-01' +%s) 3600 / 24 / 25569 + p" | sed s/'-'/'_'/ | dc
29221
The red part is the date string you want to convert. The sed in the formula above is to convert '-' to '_' which is needed to keep dc happy.

You can enter dates down to 1902-01-01.

jlinkels
 
Old 04-19-2009, 08:30 PM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Darn, unspawn was faster than me!

jlinkels
 
Old 04-19-2009, 08:36 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
Sorry for the misunderstanding.

Your question IMO did seem a bit vague and we had no way of knowing what 56778 actually represented or what you really meant by absolute. FYI Operating systems and applications do not use the same reference as starting points. linux uses seconds elapsed since 1/1/1970. Excel uses 12/31/1899 and it seems that OpenOffice uses 12/30/1899 as day 0.
 
Old 04-19-2009, 08:46 PM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by jlinkels View Post
Darn, unspawn was faster than me!
That may be so but your elaborate solution is definately more interesting than me saying "look overthere".
 
Old 04-19-2009, 08:56 PM   #12
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by unSpawn View Post
That may be so but your elaborate solution is definately more interesting than me saying "look overthere".
Well... ok... this help to overcome my disappointment a bit

BTW, I haven't seen a date related question in this forum which could not be solved with date albeit not always uncomplicated or the most elegant solution. For calculating my wife's period it can be a day or so off.

jlinkels
 
Old 04-19-2009, 08:57 PM   #13
joegumbo
Member
 
Registered: Sep 2006
Distribution: MX-16 Modified using TDE
Posts: 239

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by michaelk View Post
Sorry for the misunderstanding.

Your question IMO did seem a bit vague and we had no way of knowing what 56778 actually represented or what you really meant by absolute. FYI Operating systems and applications do not use the same reference as starting points. linux uses seconds elapsed since 1/1/1970. Excel uses 12/31/1899 and it seems that OpenOffice uses 12/30/1899 as day 0.
No offense taken; I hope none was given

I think that this does tie into the Julian calendar. Anyhow, the problem is solved.

Thanks,
-Joe

Last edited by joegumbo; 04-19-2009 at 09:03 PM.
 
Old 04-19-2009, 08:59 PM   #14
joegumbo
Member
 
Registered: Sep 2006
Distribution: MX-16 Modified using TDE
Posts: 239

Original Poster
Rep: Reputation: 32
jlinkels...
What can I say...
You are amazing!!!!
Thanks!
-Joe
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to find modified date and last accessed date of any file. parasdua Linux - Newbie 6 04-22-2008 09:59 AM
Setting system date and time affecting the clock and date on BIOS satimis Ubuntu 7 09-21-2007 08:02 AM
LXer: Absolute Linux is an absolute winner LXer Syndicated Linux News 0 08-07-2007 06:32 PM
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 08:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration