Tsql utf to local time

convert utc to est sql select CONVERT(datetime, SWITCHOFFSET(dateTimeField, DATEPART(TZOFFSET, dateTimeField AT TIME ZONE ‘Eastern Standard Time’))) tsql utf to local time select [MyUtcDate] + getdate() – getutcdate() from [dbo].[mytable]

Tsql utf to local time Read More

W3school sql

w3school sql class ClassName {   constructor() { … } } odp mysql 3wschools <?php $servername = “localhost”; $username = “username”; $password = “password”; try {   $conn = new PDO(“mysql:host=$servername;dbname=myDB”, $username, $password);   // set the PDO error mode to exception   $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);   echo “Connected successfully”; } catch(PDOException $e) {   echo “Connection failed: ” […]

W3school sql Read More

Sql how to partition rank

how to use rank function in sql BY LOVE SINGH, Here, name and id is the column name of the table tbltest. SELECT name, RANK () OVER ( ORDER BY id DESC ) price_rank FROM tbltest; sql how to partition rank SELECT * FROM ( SELECT product_id, product_name, brand_id, list_price, RANK () OVER ( PARTITION […]

Sql how to partition rank Read More

Sql last week

sql last week select min(date), max(date) from calendar where week = datepart(week, getdate() – 7) and year = datepart(year, getdate() – 7) sql select data from last week select id from tbname where date between date_sub(now(),INTERVAL 1 WEEK) and now();

Sql last week Read More

Sql server query for datediff

sql server query for datediff — DOES NOT ACCOUNT FOR LEAP YEARS DECLARE @date1 DATETIME, @date2 DATETIME, @result VARCHAR(100); DECLARE @years INT, @months INT, @days INT, @hours INT, @minutes INT, @seconds INT, @milliseconds INT; SET @date1 = ‘1900-01-01 00:00:00.000’ SET @date2 = ‘2018-12-12 07:08:01.123’ SELECT @years = DATEDIFF(yy, @date1, @date2) IF DATEADD(yy, [email protected], @date2) < […]

Sql server query for datediff Read More

Sql upsert

sql upsert update table1 set name = ‘val2’, itemname = ‘val3’, itemcatName = ‘val4’, itemQty = ‘val5’ where id = ‘val1’ if @@ROWCOUNT = 0 insert into table1(id, name, itemname, itemcatName, itemQty) values(‘val1’, ‘val2’, ‘val3’, ‘val4’, ‘val5’)

Sql upsert Read More

Sqlite make primary key

sqlite make primary key # SQLite -> //if the primary key has only one column, //you use the PRIMARY KEY column constraint //to define the primary key as follows: CREATE TABLE table_name( column_1 INTEGER NOT NULL PRIMARY KEY, … ); // in case primary key consists of two or //more columns, you use the PRIMARY […]

Sqlite make primary key Read More