Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deriving a Column that Calculates Date Difference in Minutes

Status
Not open for further replies.

bclements

IS-IT--Management
Dec 10, 2008
1
0
0
US
Hi,

I'm having some problems interpreting the below code into an expression for a derived column. I'm trying to get the difference in minutes from when a purchase order was created (this would be the CreateTime in the code) and when the order was actually shipped indicated by POReleaseTime. Is it possible to convert this code to an expression? Does anyone have examples that could get me on track? Thanks in advance.

Brian

select DateDiff(n,
(CASE WHEN DATEPART(DW, PCR.CreateDate) IN (1,7) THEN '7:00:00 AM'
WHEN DATEDIFF(n,'4:59:00 PM',PCR.CreateTime)>0 THEN '7:00:00 AM'
WHEN DATEDIFF(n,'6:59:00 AM',PCR.CreateTime)<0 THEN '7:00:00 AM'
ELSE PCR.CreateTime END),PCR.POReleaseTime) AS pMinutes
 
This will give you the difference between the createddate and releasetime in minutes (assuming that both fields are datetimes?)

Code:
DATEDIFF(MI,PCR.CreateDate,PCR.POReleaseTime)

I feel sorry for people who don't drink, when they wake up in the morning that's as good as the're going to feel all day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top