Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to extract year from date in sql

SELECT EXTRACT(YEAR FROM '2018-07-22')
Code language: SQL (Structured Query Language) (sql)
Comment

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

Extracting month from date column in SQL

SELECT Name,
MONTH(ProducedDate) AS ProducedMonth
FROM Furniture;
Comment

PREVIOUS NEXT
Code Example
Sql :: how to put value in variable mysql 
Sql :: add a day big query 
Sql :: sql server case sensitive search 
Sql :: do postgresql 
Sql :: get foreign table names mysql 
Sql :: sp in sql server 
Sql :: incompatible sql_mode=only_full_group_by 
Sql :: psql create user 
Sql :: How to add a Try/Catch to SQL Stored Procedure 
Sql :: sql select first and last record of each group 
Sql :: empty table sqlite 
Sql :: sql command to show all tables 
Sql :: sql now 
Sql :: postgresql import a database of gzip 
Sql :: mysql grant select update insert delete 
Sql :: xampp mysql version 
Sql :: with postgres 
Sql :: date in oracle 
Sql :: mysql execute file 
Sql :: sql order by alphabetical 
Sql :: insert snowflake 
Sql :: select columns postgres 
Sql :: insert into select mysql 
Sql :: tinydb add table 
Sql :: postgres week number 
Sql :: SQL Duplicates by Composite 
Sql :: pivot 
Sql :: How to insert data in mysql ? 
Sql :: sql select row with max date 
Sql :: mysql add columns 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =