Author |
Topic |
latture
Starting Member
24 Posts |
Posted - 2013-03-06 : 17:30:01
|
Hey, I think this is pretty simple and it should work but it doesn't. Any clue to why would be very helpful.select DATEDIFF(mi,i.INVDATE,i.OUTFORDELIVERY) NumBtwFinNOutThanks. |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2013-03-06 : 18:00:57
|
What doesn't work about it? All I can see is that you are missing a FROM clause.JimEveryday I learn something that somebody else already knew |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-03-06 : 18:01:48
|
What does it do? Does it give the wrong result or is it returning an error message, or is it doing something else? The syntax looks right, and assuming that INVDATE and OUTFORDELIVERY columns are of type datetime, datetime2, or smalldatetime, it should work. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-06 : 23:26:42
|
only issue i can see if one of columns being not having date values in proper format and statement throwing out of range error.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
latture
Starting Member
24 Posts |
Posted - 2013-03-07 : 08:03:53
|
I get a result of 0. I didn't put rest of the statment since those work. It's just this that doesn't. I think visakh16 could be right. I'm going to check out the format thing. Thanks! |
|
|
latture
Starting Member
24 Posts |
Posted - 2013-03-07 : 08:23:37
|
Ok. I'm getting the same freakin result. I've tried different variations of convert and cast... Here is what I have now. I'm still just getting 0 as a result.DATEDIFF(mi,CONVERT(nvarchar(30),i.INVDATE,126),CONVERT(nvarchar(30),i.OUTFORDELIVERY,126)) NumBtwFinNOutI've also tried datetime instead of nvarchar. |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2013-03-07 : 08:36:49
|
What are the data types of INVDATE and OUTFORDELIVERY? Please provide sample values for each field that are not producing the results that you expect.JimEveryday I learn something that somebody else already knew |
|
|
latture
Starting Member
24 Posts |
Posted - 2013-03-07 : 08:58:47
|
Sorry guys. I just realized that there is nothing wrong with the statement. They both had the same value so of course the result would be 0... I'm an idiot. I know. You don't have to rub it in... |
|
|
|