Solved

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

Posted on 2016-08-31
2
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Assisted Solution

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

Accepted Solution

by:
zephyr_hex (Megan) 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

740 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