I understand that i can get a number that represent the day number in a julian calendar. JDN http://en.wikipedia.org/wiki/Julian_day. For example for a date 10/10/10 i can get a number 2455479.5. My question is how to get a weeks and moths number, that means a continuous number of months or weeks like the JDN. This si very useful in reports and BI dashboards. I am using js but it can be useful for other languages.
-
_"very useful in reports and BI dashboards"_ - Really? The number of days/weeks/months since 4713 BC is useful for BI purposes? How? – nnnnnn Jan 05 '14 at 04:55
-
i think that if you have a number of weeks is easier to move on them than if you have them by year, because if i want to move 20 weeks before and is in the past year i need to know the numbers of weeks of that year, and so on... – shau Jan 05 '14 at 05:22
-
My point is that calculating 20 weeks before any given date is easy to do in JS, whereas number of weeks since 4713 BC doesn't seem like a useful concept in a business environment. – nnnnnn Jan 05 '14 at 05:28
1 Answers
The Julian Day provides a universally accepted day count from a specific point in time -- but there is no universally accepted week or month count that is comparable with the Julian Day count.
The closest thing to an official week count is the ISO 8601 standard, but it recycles every year, so it's quite different from what you're suggesting.
You could certainly extrapolate the week count from the Julian Day, simply dividing by 7. And you could come up with a month count with some basic math. I haven't tested this, but off the top of my head, I think it would be ((current year - -4713) * 12) + 2 + number of month in this year)
. (The "+ 2" is to adjust for the fact that the Julian Day count started in November, so we're adding 1 for November and 1 for December of that year. This also uses astronomical calculation [which has a Year 0] rather than historical calculation [which jumps from 1 BCE to 1 CE]; if you're using the historical calculation, adjust accordingly.)
In short, though, if you're looking to implement something that already exists and that will be recognizable to others, I think you'll find there's nothing out there.

- 3,438
- 3
- 24
- 34