You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
#!/bin/sh
myDate=$(date +"%Y-%m-%d")
echo $myDate
# 2014-01-14
echo $(date +"%Y-%m-%d_%a") # with short dayname
# 2017-01-05_Do (Do => German, localized short of Tuesday)
echo $(date +"%Y-%m-%d %H:%M:%S")
# 2014-01-14 22:15
# List of formatting options: https://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
168
SQLite
Datum, Zeit
Erster und letzter Tag des Monats ermitteln
select date('now','start of month'); --first day of current month
select date('now','start of month', '+1 months','-1 day'); --last day of current month
from datetime import date, timedelta
d=date.today()-timedelta(days=1)
output=d.isoformat()
# 2014-02-27
171
SQLite
Datum, Zeit
Gestriges Datum
select date('now','-1 day');
172
SQLite
Datum, Zeit
Zeitdifferenz
-- http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions
SELECT (strftime('%s','now') - strftime('%s',date('now','-1 day'))) AS Seconds
-- https://stackoverflow.com/questions/289680/difference-between-2-dates-in-sqlite
SELECT CAST(JulianDay('now') - JulianDay(MAX(datetime_field_in_table)) * 24 * 60 AS Integer) AS diff_minutes FROM example_table
173
T-SQL
Datum, Zeit
Zeitdifferenz
--http://msdn.microsoft.com/de-de/library/ms189794.aspx
SELECT DATEDIFF(second, '2005-12-31 23:59:59.9999999', '2006-01-01 00:00:00.0000000') AS Seconds
200
JavaScript
Datum, Zeit
Aktuelles Datum/Uhrzeit
date = new Date();
// Sat Jun 14 2014 13:15:27 GMT+0200 (CEST)
dateStringISO = date.toISOString();
// "2014-06-14T11:15:27.097Z" // Attention: Time is different because of the timezone
date.toISOString().substring(0,10);
//"2014-06-14"
dateStringISO.split("T")[1];
// 11:15:27.097Z
205
MySQL
Datum, Zeit
Tagesname
SELECT DAYNAME(NOW());
-- Monday
SELECT DAYNAME('2014-08-10');
-- Sunday
-- To get localized names switch the parameter, e.g. to German
SET lc_time_names = 'de_DE';
SELECT DAYNAME('2014-08-10');
-- Sonntag
209
SQLite
Datum, Zeit
Kalenderwoche eines Datums
-- Standard Weeknumber function from SQLite:
-- http://www.sqlite.org/lang_datefunc.html
SELECT strftime('%W', '2014-08-25')
-- The above calculation can lead to an wrong number if you expect an iso calendar week.
-- Therefore better:
-- http://stackoverflow.com/questions/15082584/sqlite-return-wrong-week-number-for-2013
SELECT
(strftime('%j', date('2014-08-25', '-3 days', 'weekday 4')) - 1) / 7 + 1 AS ISOCalendarWeekNumber;