August 15, 2009 at 2:03 pm
I am trying to come up with the script to find the number of days an order was open for the following:
Order Create Date = 1/1/07
Order Close Date = 1/1/09
How many days was the order open? Any help will be appreciated.
August 15, 2009 at 2:10 pm
DATEDIFF(day, '20070101', '20090101')
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 15, 2009 at 2:17 pm
Easy enough. Thank you very much.
August 15, 2009 at 2:48 pm
How would I get this to work?
SELECT EMP_ID, DATEDIFF(MONTH, START_DATE, END_DATE) AS HISTORY
FROM EMP_HISTORY
WHERE EMP_ID = '253'
August 15, 2009 at 3:19 pm
bpowers (8/15/2009)
How would I get this to work?SELECT EMP_ID, DATEDIFF(MONTH, START_DATE, END_DATE) AS HISTORY
FROM EMP_HISTORY
WHERE EMP_ID = '253'
DATEDIFF(m, start_date, end_date)
Suggest you look at BOL for DATEDIFF..and test out various date ranges, just to be sure that the results you are getting are what you expect
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
August 15, 2009 at 3:47 pm
bpowers (8/15/2009)
How would I get this to work?SELECT EMP_ID, DATEDIFF(MONTH, START_DATE, END_DATE) AS HISTORY
FROM EMP_HISTORY
WHERE EMP_ID = '253'
What doesn't work with the above? You can't just ask us to make something work when you don't even bother to tell us how it isn't working.
I recommend that you read the article I link to in my signature and try posting again.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 17, 2009 at 7:08 am
I got it working. Thanks.
August 17, 2009 at 12:01 pm
bpowers (8/17/2009)
I got it working. Thanks.
Heh... got what working? Did you use Jeff's algo or something else? Two way street here... let us know please. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 17, 2009 at 12:15 pm
The script I posted worked. However, the database I was using did not have any data in it. I was using it for testing purposes and whoever set it up did not populate it with data. I should have checked that first.
August 17, 2009 at 12:56 pm
Ah... I hate it when that happens. Thanks for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply