SQL Date Queries
Perform a series of queries in a data array in date format with Sql Date queries.

Index
- Database Date Queries
- SQL Today ()
- SQL Yesterday ()
- SQL First Day of the Week
- Last Day of the Week
- Last time on the first day of the week
- The last day of the last week
- First Day of the Month
- Last Day of the Month
- First Day of last month
- Last day of last month
- First Day of the Year
- Last day of the year
- First Day of last year
- Last day of last year
Database Date Queries
There is no limit to what you can do with SQL Date Queries. Especially terms like timestamp and universal time are the most needed time objects today. In the previous articles Sql DateDiff I have created useful clauses about Sql Date Queries that will help you a lot especially when logging.
SQL Today ()
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
SQLSQL Yesterday ()
SELECT DATEADD(d,-1,GETDATE())
SQLSQL First Day of the Week
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
SQLLast Day of the Week
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
SQLLast time on the first day of the week
SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0)
SQLThe last day of the last week
SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6)
SQLFirst Day of the Month
SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
SQLLast Day of the Month
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))
SQLFirst Day of last month
SELECT DATEADD(mm,-1,DATEADD(mm, DATEDIFF(mm,0,GETDATE( )),0))
SQLLast day of last month
SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD
(mm,DATEDIFF(mm,0,GETDATE()),0)))
SQLFirst Day of the Year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))
SQLLast day of the year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))
SQLFirst Day of last year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))
SQLLast day of last year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))
SQLWith these SQL queries you can return interesting results in MS SQL database. I have shared a few time queries that will be useful for you while preparing a campaign on an E-commerce site, or keeping log records with a universal timestamp. Apart from these, there are other date queries. The reason I chose these queries is that they return very interesting results.
MAKE A COMMENT
COMMENTS - 0 COMMENTS