Calc return date from Date Calculations every trip To add a certain number of days to a date, you can use the AddDate or SubDate functions Examples: AddDate(CurDate(), 45) SubDate(CurDate(), 30) To add months or years, you can use the second version of the AddDate or SubDate function. Using interval AddDate(datevalue, value intType) Interval is either Day, Week, Month or Year intType is the number of days, months or years you value Using + (note format) want to add is the name of the field or another date datevalue value you want to add to. Newer versions of MySQL even allow you to add Using + interval intervals to dates by simply using the + operator Subtraction works too Examples: Select checkOutDate, AddDate(checkOutDate, Interval 14 Day) As dueDate From tblLibrary; Select CustName, AddDate(startDate, Interval 18 Month) As subscriptionEnd From tblSubscribers; Select checkOutDate, checkOutDate + Interval 14 Day As dueDate From tblLibrary; Show a list all employees Concatenating Strings and their hire dates in one To concatenate strings in MySQL, you must use the field. work Concat function: neither “+” nor “&” Surround literals with apostrophes You CAN include numeric fields in a Concat statement Example: Select Concat(City, ', ', State, ' ', Zip) As CSZ From tblCustomer;
Date Calculations To add a certain number of days to a date, you can use the AddDate or SubDate functions Examples: AddDate(CurDate(), 45) SubDate(CurDate(), 30) To add months or years, you can use the second version of the AddDate or SubDate function. AddDate(datevalue, Interval value intType) intType is either Day, Week, Month or Year value is the number of days, months or years you want to add datevalue is the name of the field or another date value you want to add to. Newer versions of MySQL even allow you to add intervals to dates by simply using the + operator Subtraction works too Examples: Select checkOutDate, AddDate(checkOutDate, Interval 14 Day) As dueDate From tblLibrary; Select CustName, AddDate(startDate, Interval 18 Month) As subscriptionEnd From tblSubscribers; Select checkOutDate, checkOutDate + Interval 14 Day As dueDate From tblLibrary; Calc return date from every trip Using interval Using + (note format) Using + interval Concatenating Strings To concatenate strings in MySQL, you must use the Concat function: neither “+” nor “&” work Surround literals with apostrophes You CAN include numeric fields in a Concat statement Example: Select Concat(City, ', ', State, ' ', Zip) As CSZ From tblCustomer; Show a list all employees and their hire dates in one field.
3%20-%20Single%20Table%20Queries.docx