Results 1 to 2 of 2

Thread: SQL, Acess & Dates?!?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    88

    Question

    Hi Guys,

    My database has a date time stamp, heres an example.

    1/5/2001 9:46:23 AM
    D/M/YYYY H:MM:SS ??

    I need to know the number of days/hours/mins since this date using sql. Is this possible? I can do it with Now() to find the days, but I could really do with it being a little more detailed.

    Anyhelp much appreciated as always,

    Paul.
    Set MCP = NTServer + NTWorkstation

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    You could use DateDiff. You might have to return the values separately and calculate the difference.

    i.e.

    days = DateDiff("d", Date1, Date2)
    hours = DateDiff("h", date1, Date2)-(DateDiff("d", Date1, Date2)*1440) [24 hours per day]
    minutes = DateDiff("n", date1, Date2)-(DateDiff("d", Date1, Date2)*1440) [60 * 24 = 1440 minutes per day]
    seconds = DateDiff("s", date1, Date2)-(DateDiff("d", Date1, Date2)*86400) [60 * 60 * 24 = 86400 seconds per day]

    I am sure there must be an easier way but I cannot think of it off the top of my head!

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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