Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SYSDATE Year

Status
Not open for further replies.
Aug 27, 2012
1
US
I created the following sql statement. However, I do not want to hardcode the date '01-JAN-2012'. I would like to have 01/01 but derive the year from the sysdate.

Effdt <> TO_DATE('01-JAN-2012','DD/MM/YYYY');
 
This will return the first of the current year

SELECT DATEADD(yy, DATEDIFF(yy, 0, Getdate()), 0) as FirstDayOfYear

Ian
 
Sorry that will not work, I wrongly assumed MYSQL Dateadd and DateDiff worked in same way as SQL server

The syntax you have used looks more like Oracle! Are you in the right forum?

Ian
 
Assuming you are using MySQL and not some other DBMS then something like this should work:

Code:
Effdt <> CONCAT( YEAR( NOW() ), '01-01' )

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top