A. Date and Time
-- MariaDB MySQL
select curdate() as tanggalskrng;
SELECT DAYNAME(curdate()) as haritanggal;
select date(NOW()) - interval 1 day as onedayagotanggal;
SELECT DAYNAME(date(NOW()) - interval 1 day) as harionedayagotanggal;
select current_timestamp() as dateandtimelast;
select date(current_timestamp()) as onlydatetimelast;
select DAYNAME(current_timestamp()) as haridateandtimelast;
select @@hostname as hostname,curdate() as tanggalskrng,DAYNAME(curdate()) as haritanggal,date(NOW()) - interval 1 day as onedayagotanggal,
DAYNAME(date(NOW()) - interval 1 day) as harionedayagotanggal,current_timestamp() as dateandtimelast,date(current_timestamp()) as onlydatetimelast,
DAYNAME(current_timestamp()) as haridateandtimelast,'Teguh Triharto' as Remaks;
-- SQL Server
SELECT CAST( GETDATE() AS Date) as tanggalskrng;
select DATENAME(w,getdate()) as haritanggal;
SELECT DATEADD(day, -1, CAST(GETDATE() AS date)) AS YesterdayDate;
SELECT DATENAME(w,DATEADD(day, -1, CAST(GETDATE() AS date))) as hariYesterdayDate;
SELECT GETDATE() as dateandtimelast;
select DATENAME(w,getdate()) as haridateandtimelast;
select CURRENT_TIMESTAMP as currentimelast;
select 'Teguh Triharto' as Remaks;
select @@servername as Hostname, CAST( GETDATE() AS Date) as tanggalskrng,DATENAME(w,getdate()) as haritanggal,DATEADD(day, -1, CAST(GETDATE() AS date)) AS YesterdayDate,
DATENAME(w,DATEADD(day, -1, CAST(GETDATE() AS date))) as hariYesterdayDate,GETDATE() as dateandtimelast,DATENAME(w,getdate()) as haridateandtimelast,
CURRENT_TIMESTAMP as currentimelast,'Teguh Triharto' as Remaks;
B. if statement
-- MariaDB MySQL
select @@hostname as hostname, IF(DAYNAME(curdate())='monday', 'select @@hostname', 'select @@version') as ifstatement,'Teguh Triharto' as remaks;
select @@hostname as hostname, IF(DAYNAME(curdate())='monday', (select @@hostname), (select @@version)) as ifstatement,'Teguh Triharto' as remaks;
-- SQL Server
IF DATENAME(w,getdate())='monday'
SELECT 'Weekday' as xx;
ELSE
SELECT 'Weekend' as yy;
IF DATENAME(w,getdate())='monday'
SELECT @@SERVERNAME as hostname;
ELSE
SELECT @@version as version;
DAYNAME(date(NOW()) - interval 1 day) as harionedayagotanggal,current_timestamp() as dateandtimelast,date(current_timestamp()) as onlydatetimelast,
DAYNAME(current_timestamp()) as haridateandtimelast,'Teguh Triharto' as Remaks;
-- SQL Server
SELECT CAST( GETDATE() AS Date) as tanggalskrng;
select DATENAME(w,getdate()) as haritanggal;
SELECT DATEADD(day, -1, CAST(GETDATE() AS date)) AS YesterdayDate;
SELECT DATENAME(w,DATEADD(day, -1, CAST(GETDATE() AS date))) as hariYesterdayDate;
SELECT GETDATE() as dateandtimelast;
select DATENAME(w,getdate()) as haridateandtimelast;
select CURRENT_TIMESTAMP as currentimelast;
select 'Teguh Triharto' as Remaks;
select @@servername as Hostname, CAST( GETDATE() AS Date) as tanggalskrng,DATENAME(w,getdate()) as haritanggal,DATEADD(day, -1, CAST(GETDATE() AS date)) AS YesterdayDate,
DATENAME(w,DATEADD(day, -1, CAST(GETDATE() AS date))) as hariYesterdayDate,GETDATE() as dateandtimelast,DATENAME(w,getdate()) as haridateandtimelast,
CURRENT_TIMESTAMP as currentimelast,'Teguh Triharto' as Remaks;
B. if statement
-- MariaDB MySQL
select @@hostname as hostname, IF(DAYNAME(curdate())='monday', 'select @@hostname', 'select @@version') as ifstatement,'Teguh Triharto' as remaks;
select @@hostname as hostname, IF(DAYNAME(curdate())='monday', (select @@hostname), (select @@version)) as ifstatement,'Teguh Triharto' as remaks;
-- SQL Server
IF DATENAME(w,getdate())='monday'
SELECT 'Weekday' as xx;
ELSE
SELECT 'Weekend' as yy;
IF DATENAME(w,getdate())='monday'
SELECT @@SERVERNAME as hostname;
ELSE
SELECT @@version as version;
No comments:
Post a Comment