Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to extract only year and month from date in sql

SELECT FORMAT(<your-date-field>,"YYYY-MM") AS year-date FROM <your-table>
Comment

sql get month and year from date

DECLARE @date date = '04-18-2020' --date for act;
SELECT YEAR(date), MONTH(date)    --, DAY(date) add if u want day
Comment

sql date with month and year only

SELECT
   DATEADD(MONTH, DATEDIFF(MONTH, 0, <dateField>), 0) AS [year_month_date_field]
FROM
   <your_table>
Comment

PREVIOUS NEXT
Code Example
Sql :: remove all spaces from string sql 
Sql :: Split JSON data in SQL Server column 
Sql :: sql check if table exists 
Sql :: sql select 
Sql :: date less than in sql 
Sql :: how to update values in sql 
Sql :: xampp mysql command to import a large database 
Sql :: timestamp sql 
Sql :: postgresql variable in query 
Sql :: select only distinct values another table 
Sql :: sql comments 
Sql :: delete table sqlite 
Sql :: first max salary in sql 
Sql :: postgresql having 
Sql :: peewee print sql 
Sql :: sqlyog clear cache query 
Sql :: fetlife 
Sql :: SQL division of an integer by another integer get float CAST 
Sql :: top frequency in sql server 
Sql :: psql concat string and int 
Sql :: difference in dates sql 
Sql :: Syntax error or access violation: 1075 Incorrect table def inition; there can be only one auto column and it must be defined as a key 
Sql :: mysql remove tabs from string 
Sql :: generate random data in mysql 
Sql :: mysql delet from the child table when we delete the rows from the parent 
Sql :: drop procedure postgres 
Sql :: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 
Sql :: mysql undo delete 
Sql :: MySQL error code 2068 
Sql :: trigger in mysql 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =