• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Try understand the query with datediff()

 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Can someone explain to me what does this query mean ?



I understand the output will have two columns named OPEN_DATETIME and Aging, but what does the two parameters in datediff() means? What did 2016-12-13 23:59:59 and 2016-12-14 23:59:59 mean ?
 
Saloon Keeper
Posts: 15485
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,

Did you Google for datediff? The first few hits explain exactly what the parameters mean.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing to do would be to find out the datediff function does for that particular database.
What database is it a query for?
Oracle?  MySQL?  SQLServer?
 
John Joe
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Hi John,

Did you Google for datediff? The first few hits explain exactly what the parameters mean.[/quote

Yes, I did. I just don't understand the parameter inside the method.

 
John Joe
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:The first thing to do would be to find out the datediff function does for that particular database.
What database is it a query for?
Oracle?  MySQL?  SQLServer?



MySQL.
 
Stephan van Hulst
Saloon Keeper
Posts: 15485
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, DATEDIFF takes two datetimes and returns the difference, so the two arguments you pass represent dates/times.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Joe wrote:What did 2016-12-13 23:59:59 and 2016-12-14 23:59:59 mean ?



Those are literal values which refer to a particular time on a particular date. The first one means 2016 December 13th at 59 minutes and 59 seconds past hour 23, which many people refer to as 11 PM. (If you're still a bit confused, the "12" is because December is the 12th month.) So you have "Year-Month-Day Hour:Minute:Second". You should be able now to explain what the second one means, I hope.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic