Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31

    Unanswered: Datediff function help!

    I have to date field
    Startdate:
    EndDate

    How to use EndDate - StartDate????
    Datediff function allow you to chose 1 date variable only
    mine have to enter 2 date
    how?????

  2. #2
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31

    Re: Datediff function help!

    Originally posted by zw^
    I have to date field
    Startdate:
    EndDate

    How to use EndDate - StartDate????
    Datediff function allow you to chose 1 date variable only
    mine have to enter 2 date
    how?????
    I have 2 date field
    Startdate:
    EndDate:

    How to use EndDate - StartDate????
    Datediff function allow you to chose 1 date variable only
    mine have to enter 2 date
    how?????

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721

    Re: Datediff function help!

    Originally posted by zw^
    I have 2 date field
    Startdate:
    EndDate:

    How to use EndDate - StartDate????
    Datediff function allow you to chose 1 date variable only
    mine have to enter 2 date
    how?????
    DateDiff takes at least 3 parameters:

    DateDiff(<datepart>, <date1>, <date2>)

    Datepart is a character representing the part of the date to return the value a (YYYY = Year, Q = Quarter, M = Month, D = Day, W = Weekday, WW = Week, H = Hour, N = Minute, S = Second)

    Date1 is the first date in the comparison.

    Date2 is the second date in the comparison.

    Code:
    Response.Write DateDiff("YYYY", Now, "1/1/2000")
    That should return "3" (if it's negative, just switch the dates)
    That which does not kill me postpones the inevitable.

  4. #4
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    but mine have to enter the 2 date from the form because i have a form for people to submit their startdate and enddate.

  5. #5
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Originally posted by zw^
    but mine have to enter the 2 date from the form because i have a form for people to submit their startdate and enddate.
    Ok...

    Code:
    Dim dtStartDate, dtEndDate
    
    dtStartDate = Request.Form("StartDate")
    dtEndDate = Request.Form("EndDate")
    
    Response.Write DateDiff("N", dtStartDate, dtEndDate)
    That should show the numbers of minutes between the two dates...
    That which does not kill me postpones the inevitable.

  6. #6
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    thanks Seppuku

  7. #7
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    Seppuku can ask u if i wan to dispkay the price of the car wat should i do ?

    i got 2 table rental and car.
    rental contain the particulars of member and the car they chose to rent
    car contain the car_no, model and daily rate.
    how to retrieve daily rate from database??????

    i write response.write(oRS("Daily Rate"))
    but this error appear
    ADODB.Recordset error '800a0cc1'

    Item cannot be found in the collection corresponding to the requested name or ordinal.
    Last edited by zw^; 10-17-03 at 15:18.

  8. #8
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Can you post the whole ASP code including the database connection code?
    That which does not kill me postpones the inevitable.

  9. #9
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    for my car table , i never do connection
    i just create a car table and display all the car in another page.

  10. #10
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Originally posted by zw^
    for my car table , i never do connection
    i just create a car table and display all the car in another page.
    I'm not sure I understand.. if you can, it would be helpful to see some code
    That which does not kill me postpones the inevitable.

  11. #11
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    31
    It is now working, Thanks anyway for your help .
    Thanks

Posting Permissions

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