Date calculations

  • I'm running a VB front end with SQL Server database. Im currently converting from an Access database. I need to find an average lead time for items purchased. this would be avg(dteReceived-dteOrdered) but I do not know how to run a date conversion. any suggestions would be appreciated.


    "The grass is always greener over the septic tank." ~Leaf

  • Use DATEDIFF ( datepart , startdate , enddate ) funcation.

    USE pubs

    GO

    SELECT DATEDIFF(day, pubdate, getdate()) AS no_of_days

    FROM titles

    GO

  • GREAT! it works

    final code:

    Avg(DATEDIFF(day,[dteprinted],[dtereceived])) AS AvgLead


    "The grass is always greener over the septic tank." ~Leaf

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply