Solved

How to count the amount of days from a date in the past

Posted on 2016-08-31
2
37 Views
Last Modified: 2016-08-31
I want to show the amount of days a product has been in our possession since received(dbo.WOMAST01B.recdate) to today's date. I want to show this count in a column named "Days Left". Any help will be appreciated.

SELECT     dbo.WOMAST01B.step, dbo.WOMAST01B.wono AS WO, dbo.WOMAST01B.item AS PN, dbo.WOMAST01B.location, dbo.WOMAST01B.dept AS SHOP, 
                      dbo.WOMAST01B.location2 AS [ASSIGNED EMPLOYEE], dbo.WOLABO01B.prempl, dbo.WOLABO01B.time, dbo.WOMAST01B.recdate AS [DAYS LEFT]
FROM         dbo.WOMAST01B LEFT OUTER JOIN
                      dbo.WOLABO01B ON dbo.WOMAST01B.wono = dbo.WOLABO01B.wono
WHERE     (dbo.WOMAST01B.dept = 'AVI')

Open in new window

0
Comment
Question by:maximus1974
2 Comments
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 41778773
0
 
LVL 42

Accepted Solution

by:
zephyr_hex earned 250 total points
ID: 41778795
I'm assuming recdate is a date data type.

SELECT DATEDIFF(dd,dbo.WOMAST01B.recdate, GETDATE()) AS [Days Left]

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now