Link to home
Create AccountLog in
Avatar of romeiovasu
romeiovasu

asked on

date diff in sql

i have a query which shows datediff if it is received today it shows null value how can i show 0 instead of null value.

SELECT T1.[ItemCode], T1.[ItemName], T0.[WhsCode], T0.[IntrSerial], T0.[CreateDate] as [IntoSystem],DATEDIFF(DAY,Convert(nvarchar,T0.CreateDate,101),Convert(nvarchar,getdate(),101)) as NoOfDays FROM OSRI T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[Status] = 0 ORDER BY T0.[WhsCode], T0.[ItemCode]
SOLUTION
Avatar of nunga
nunga
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of romeiovasu
romeiovasu

ASKER

i tried that already it sill gives me null value.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SELECT T1.[ItemCode], T1.[ItemName], T0.[WhsCode], T0.[IntrSerial], T0.[CreateDate] as [IntoSystem],ISNULL(DATEDIFF(DAY,Convert(nvarchar,T0.CreateDate,101),Convert(nvarchar,getdate(),101)),0) as NoOfDays FROM OSRI T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[Status] = 0 ORDER BY T0.[WhsCode], T0.[ItemCode]
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account