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.
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
212
SQLite
Datum, Zeit
Tagesname
-- There is no build in solution. Because of this you have to build a solution out of the weekday.
-- Be careful, the first weekday (0) is a sunday
SELECT
,CASE CAST(strftime('%w', myDateField) as integer)
WHEN 0 then 'Sonntag'
WHEN 1 then 'Montag'
WHEN 2 then 'Dienstag'
WHEN 3 then 'Mittwoch'
WHEN 4 then 'Donnerstag'
WHEN 5 then 'Freitag'
WHEN 6 then 'Samstag'
ELSE '????????????????????' END AS Tag_der_Woche_Deutsch
,CASE CAST(strftime('%w', myDateField) as integer)
WHEN 0 then 'Sunday'
WHEN 1 then 'Monday'
WHEN 2 then 'Tuesday'
WHEN 3 then 'Wednesday'
WHEN 4 then 'Thursday'
WHEN 5 then 'Friday'
WHEN 6 then 'Saturday'
ELSE '????????????????????' END AS Day_of_week_English
202
PHP
Fallunterscheidung
Ternary operator
$testVar = "OK";
$resultVar;
$resultVar = $testVar=="OK" ? true : false;
// same as if-else construction
if ($testVar == "OK")
{
$resultVar = true;
}
else
{
$resultVar = false;
};
203
Java
Filehandling
Ternary operator
String thisVar = "OK";
boolean resultVar;
resultVar = thisVar.equals("OK") ? true : false;
// same as if-else construction
if (thisVar.equals("OK"))
{
resultVar = true;
}
else
{
resultVar = false;
}
204
Python
Fallunterscheidung
Ternary operator
thisVar = "OK"
resultVar = False
# [on_true] if [cond] else [on_false]
resultVar = True if thisVar == "OK" else False
// same as if-else construction
if (thisVar == "OK"):
resultVar = True
else:
resultVar = False
248
PowerShell
Fallunterscheidung
Ternary operator
## Example from here: https://www.kongsli.net/2012/02/23/powershell-another-alternative-to-ternary-operator/
$thisVar='OK'
$resultVar = @{$true=1;$false=2}[$thisVar -eq 'OK']
// same as if-else construction
if ($thisVar -eq 'OK')
{
$resultVar = 1;
}
else
{
$resultVar = 2;
}
import json
myJSONFile = "/tmp/Test/myData.json"
json_data = open(myJSONFile)
# In Python werden JSON Daten nach dem Laden wie Dictionaries behandelt
data_dict = json.load(json_data)
195
Python
Exceptions
Exception auslösen
if (a!=b):
raise Exception("Not implemented, yet")
194
Python
Filehandling
Filename-Manipultation Basics
import os
myFilename = "/tmp/Test/myFile.txt"
# Get only the path
path_only = os.path.dirname(myFilename)
# /tmp/Test
# Filename only
filename_only = os.path.basename(myFilename)
# myFile.txt
# get only filename without extention
filename_without_ext = os.path.basename(os.path.splitext(myFilename)[0])
# myFile
# get only the extension
filename_extention_only = os.path.splitext(myFilename)[1]
# .txt
# put them together again
myFilename_together = os.path.join(path_only, filename_without_ext + filename_extention_only)
# /tmp/Test/myFile.txt