1. Advertising
    y u no do it?

    Advertising (learn more)

    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
     
    JJnacy, Aug 30, 2009 IP
  2. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nyxano, Aug 30, 2009 IP
    JJnacy likes this.
  3. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    JJnacy, Aug 30, 2009 IP
  4. pons_saravanan

    pons_saravanan Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    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)
     
    pons_saravanan, Aug 31, 2009 IP
    JJnacy likes this.
  5. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    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?
     
    JJnacy, Aug 31, 2009 IP
  6. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    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.
     
    nyxano, Aug 31, 2009 IP
  7. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    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.
     
    JJnacy, Aug 31, 2009 IP
  8. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    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.
     
    nyxano, Aug 31, 2009 IP
  9. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    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
    camjohnson95, Sep 1, 2009 IP
  10. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    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.
     
    JJnacy, Sep 4, 2009 IP