In GETDATE() function will return current date and time from the SQL Server.
To get current year, I combine YEAR with GETDATE = YEAR(GETDATE());
select YEAR(GETDATE())AS current_year;
select datepart(yyyy,getdate())AS current_year;select datepart(MM,getdate()) AS current_month;
select datepart(dd,getdate()) AS current_day;
OUTPUT:
current_year |
2016 |
current_year |
2016 |
current_month |
2 |
current_day |
18 |
2016 //current year
2016 //current year
2 //current Month
18 //current day
Post your comments / questions
Recent Article
- ModuleNotFounEerror:No module named celery in Django Project
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
Related Article