Monday, May 5, 2014

sql datediff

sql datediff function returns the time between two dates

datediff(date_1, date_2)

for example

select datediff('2014-03-05', '2014-03-04')

returns

1

sql substr

sql substr function is the abbreviated form of substr, In MySQL for example these are the options:

substr(str,pos)
substr(str FROM pos)
substr(str, pos. len)
substr(str FROM pos FOR len)

where str is the string, pos the starting poisition and len the length of the substring retrived by the function.