3 Replies - 822 Views - Last Post: 11 October 2012 - 07:57 AM

#1 Scorpion_134  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 11

Understanding Line in SQL Statement

Posted 11 October 2012 - 06:37 AM

I have recently started learning more and more about SQL, but this statement has me confused. If you could tell me what this means that would be great. Thanks!!

(DateDiff(dd, ISNULL(x.CDate, '1/1/1900'), y.DDate) > 5)


Is This A Good Question/Topic? 0
  • +

Replies To: Understanding Line in SQL Statement

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: Understanding Line in SQL Statement

Posted 11 October 2012 - 07:10 AM

Just break it down.


(DateDiff '-- you want to read about datediff here.
(dd, '-- from that link dd is day.. so are getting the number of days between two dates.
ISNULL('-- you should read about isnull here.
x.CDate, '-- some column name
'1/1/1900') '-- if that column is null then use this date.
, y.DDate) '-- find the number of days between x.CDate (or 01/01/1900 if x.Cdate is null) to y.Ddate
> 5)

'-- if that number of days between said dates is greater than five return true or else false.
Was This Post Helpful? 1
  • +
  • -

#3 Scorpion_134  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 11

Re: Understanding Line in SQL Statement

Posted 11 October 2012 - 07:44 AM

View Postmodi123_1, on 11 October 2012 - 07:10 AM, said:

Just break it down.


(DateDiff '-- you want to read about datediff here.
(dd, '-- from that link dd is day.. so are getting the number of days between two dates.
ISNULL('-- you should read about isnull here.
x.CDate, '-- some column name
'1/1/1900') '-- if that column is null then use this date.
, y.DDate) '-- find the number of days between x.CDate (or 01/01/1900 if x.Cdate is null) to y.Ddate
> 5)

'-- if that number of days between said dates is greater than five return true or else false.



Thanks for your Reply. I am somewhat new to SQL so I was just making sure I was reading it correctly.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: Understanding Line in SQL Statement

Posted 11 October 2012 - 07:57 AM

Hmmm.. well next time I'll have to make you tell me what you think it says first. Also I just noticed this is mysql not mssql... the function explanation is the same but you may get a bit more mileage out of hitting up the mysql search bar.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1