[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

DATEDIFF -- dd vs yy

is
DATEDIFF(yy, COLUMN1, COLUMN2 ) <=1
exactly same as
DATEDIFF(dd, COLUMN1, COLUMN2 ) <=365)

DATEDIFF(yy, COLUMN1, COLUMN2 ) BETWEEN 1 and 2
exactly same as
DATEDIFF(dd, COLUMN1, COLUMN2 ) BETWEEN 366 and 730
0
25112
Asked:
25112
  • 3
  • 2
4 Solutions
 
Rajkumar GsSoftware EngineerCommented:
No.

2011.01.01 &
2012.12.12
will have different results
0
 
25112Author Commented:
so
SELECT DATEDIFF(yy, '2011/01/01', '2012/12/12' )
does not look days but only the year part?
0
 
Rajkumar GsSoftware EngineerCommented:
Similarly for your second query,
2011.01.01 &
2013.12.12
won't work
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Rajkumar GsSoftware EngineerCommented:
yes. Since
Yy - looks only year part
dd - only looks day part.
0
 
TempDBACommented:
This is because of the feature of the function. It first extract the datepart that is provided as a first argument, from second and third argument, and then subtracts. If its year, than only year part will be taken from full datetime, if month then only month. Similarly it happens for day, hour,second. You can only get an integer value of the datepart you are looking for basically.
It is very nicely shown by the example chosen by RajkumarGS.
0
 
25112Author Commented:
helped - thanks
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now