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
Thanks I did try but. It was a very strange result ! DateDiff("d","8/19/2009","8/13/2009") ===> result is -6
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)
Thanks you are right. Yet I tried DateDiff("d","1/1/0001","8/23/2002") it showed another strange result ===> 599 why?
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.
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.
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.
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?
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.