y u no do it?

Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just \$1 per CPM or \$0.10 per CPC.

How to get the total days from 01/01/0001 to today?

Discussion in 'C#' started by JJnacy, Aug 30, 2009.

1. #1
example today = 8/30/2009 as a variable.

Question:
Has any simple classic ASP script can easily to know how many days from 01/01/0001 to 8/30/2009 ?

Thanks

Aug 30, 2009 IP
2. nyxanoPeon

Messages:
417
15
0
Trophy Points:
0
#2
Aug 30, 2009 IP
JJnacy likes this.
3. JJnacyPeon

Messages:
448
5
0
Trophy Points:
0
#3
Aug 30, 2009 IP
4. pons_saravananPeon

Messages:
28
1
0
Trophy Points:
0
#4
you have to swap the dates

the first date must be smaller than the second date. then you will get positive result(as per your sample it will be 6)

Aug 31, 2009 IP
JJnacy likes this.
5. JJnacyPeon

Messages:
448
5
0
Trophy Points:
0
#5
Thanks you are right.

Yet I tried
DateDiff("d","1/1/0001","8/23/2002")
it showed another strange result ===> 599

why?

Aug 31, 2009 IP
6. nyxanoPeon

Messages:
417
15
0
Trophy Points:
0
#6
Because there is no such year as 0001 in ASP. 0001 is treated as 01 and when you use a two digit year, it assumes you are using a short hand year (ie: 01 as opposed to 2001) so it calculates the number of days from the date in that year.

The furthest back you can go is Year 100 because 99 would be treated as 1999. Calculate the number of days from 01/01/100 then add the rest of the days for 100 years manually.

I don't think any script can calculate from year 1 simply because of two digit short hand for years.

Aug 31, 2009 IP
7. JJnacyPeon

Messages:
448
5
0
Trophy Points:
0
#7
Thanks,

I was trying to figure out how to do like http://calendars.alldiy.com to calculate days

I was hoping if there is an easy way to do that.

Aug 31, 2009 IP
8. nyxanoPeon

Messages:
417
15
0
Trophy Points:
0
#8
I don't think they are using a programming language's built in function. I would guess they are using some sort of math function to do the calculation instead.

Aug 31, 2009 IP
9. camjohnson95Active Member

Messages:
737
17
0
Trophy Points:
60
#9
I don't know if this would work but what if you went:
DateDiff("d","1/1/1001","8/23/3002")
e.g: add 1000 years to the start and end dates if start date is less then 1000
The result should still be the same shouldn't it?

Last edited: Sep 1, 2009
Sep 1, 2009 IP
10. JJnacyPeon

Messages:
448
5
0
Trophy Points:
0
#10
Thanks

very creative way

I have tried http://calendars.alldiy.com and it seem to have same results.

1/1/1001 ==> 365250 days
8/23 /2002==>731100 days
8/23/3002 ==> 1096350 days

I guess it might be working too by your way.

Sep 4, 2009 IP