Results 1 to 7 of 7

Thread: Calculating Dates

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Posts
    87
    Greetings..

    How could I get the scale of the number of days, hours, minutes, seconds from two different general date format... ie.

    11/11/11 11:11 AM and 12/12/12 12:12 AM

    will give an output of

    1 month
    1 day
    1 hour
    1 minutes

    get what i mean??

    now how do i write the code..

    thanks in advance to those who reply
    MohamadHassan<equuelus@icqmail.com>

    Javascript,VBScript,ASP,LearningVBfor.NET

    ICQ:7205608

  2. #2
    Addicted Member Active's Avatar
    Join Date
    Jan 2001
    Location
    Lat: 13° 4' 46" N, Long: 80° 15' 20" E
    Posts
    209
    11/11/11 11:11 AM and 12/12/12 12:12 AM

    will give an output of

    1 month
    1 day
    1 hour
    1 minutes
    Do you want the difference between the month parts
    Difference between the dateparts and the Difference
    Between yearparts.. ....(That will be like what you have written above ...but seems useless..)

    or

    You want the exact Number of days,months,Years etc.. between two given dates in different format ?
    If you can't beat your computer at chess, try kickboxing !!!
    [Download Tag Editing Tools.]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Posts
    87
    yea.. i want the exact no. of hours, days, month, years..ect..between two given dates..

    thanks for your reply guru.
    MohamadHassan<equuelus@icqmail.com>

    Javascript,VBScript,ASP,LearningVBfor.NET

    ICQ:7205608

  4. #4
    Guest
    Use the DateDiff function.

  5. #5
    Guest
    Here is the syntax for the DateDiff function.


    Syntax

    DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

    The DateDiff function syntax has these named arguments:

    Part - Description
    interval - Required. String expression that is the interval of time you use to calculate the difference between date1 and date2.
    date1, date2 - Required; Variant (Date). Two dates you want to use in the calculation.
    firstdayofweek - Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.
    firstweekofyear - Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.



    Settings

    The interval argument has these settings:

    Setting - Description
    yyyy - Year
    q - Quarter
    m - Month
    y - Day of year
    d - Day
    w - Weekday
    ww - Week
    h - Hour
    n - Minute
    s - Second

    Usage


    Code:
    ?DateDiff("m", "11/11/11", "12/12/12")

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Posts
    87
    thanks matthew

    that was really helpful..emm.. wondering where could i find good reference on built in vb functions plus the syntax..
    MohamadHassan<equuelus@icqmail.com>

    Javascript,VBScript,ASP,LearningVBfor.NET

    ICQ:7205608

  7. #7
    Guest
    If you are using VB, and have it installed along with a help file (or MSDN Libary), everything is listed in there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width