i want to retrieve the last two digits of current year for ex- i want to retrieve "13" from current year "2013'. help me provide a suitable query for this
Thanx
Use the YEAR() function to retrieve the year value from a date/datetime/timestamp column in MySQL. This function takes only one argument – a date or date and time. This can be the name of a date/datetime/timestamp column or an expression returning one of those data types.
Hopefully, now you can easily get last one month data in MySQL. Similarly, if you want to get records for past one month rolling, that is, last 30 days, then here's the SQL query for it. select * from orders where order_date>now() - interval 1 month; In the above query, we select rows after past 1 month interval.
MySQL YEAR() Function The YEAR() function returns the year part for a given date (a number from 1000 to 9999).
try this one
SELECT DATE_FORMAT(datefield, '%y')
use DATE_FORMAT
SELECT DATE_FORMAT(CURDATE(), '%y')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With