How to insert a invoice data to db in codeigniter - codeigniter-3

Any one can help me how to insert a invoice data to db in codeigniter. I am beginner to development. I have no idea how to insert and how is handle database .

Invoice table have invoice date field that field type date and default values current date you choose its automatically taking system date of your invoice date. Or
$invoicedate = date("Y-m-d");
$insertdata = array("invoice_date" =>$invoicedate,"invoice_amount" =>560);
$this->db->insert(insertdata);

Related

MySQLWorkbench How to create Date only column to be updated every time I ingest new data

I already have a date time column which is updated every time I ingest new data and it works, but I would like to do the same for a new column but just with the date, not the time. Please see the picture attached. What should I write in the Default option? Table column definitions
You could set the default value to CURRENT_DATE ON UPDATE CURRENT_DATE in your EventDate field.
But wouldn't it be better to extract date from the already existing EventDateTime field with DATE_FORMAT(EventDateTime, '%Y-%m-%d') or DATE(EventDateTime) functions?

From and To date in calendar selector not fetching required data

I created calendar selector on date attribute.
when I select only From date, I get a message'No data returned for this view'.
when I select only To date,I am able to fetch all data values.
when I select From date and To date together, I get a Message "No data returned for this view".
when I run the report without any date selection (empty dates), I am able to fetch all data values.
I need related data values between From date and To date as per date selection.

db2 getting business dates between given dates

I have a table called "Publicholidays" where in dates are stored as Varchar.
My query should fetch all values from say table xxxx between the user selected dates that exclude the weekends(sat,sun), public holidays. I am new to DB2 so can anyone suggest me ideas please
Note: in DB dates are stored as String.
Mistake #1 - Storing dates as strings. Let's hope you have at least stored them YYYY-MM-DD and not MM-DD-YYYY.
Mistake #2 - Instead of a "Publicholidays" table, you need a Calendar (aka Dates or date conversion) table. It should have a record for every day along with a few flag columns BUSINESS_DAY, WEEKEND, PUBLIC_HOLIDAY. Alternatively, you could have a single DAY_TYPE column with values for business day, weekend and holiday. You'll also want to have a STRING_DATE column to make conversion between your string date and a true date easier.
Google SQL Calender table and you'll find lots of examples and discussions.
Lastly, strongly consider fixing your DB to store dates in a date column.

SQLite in iPhone:I want to Retrieving 1 row for each date from sqlite

i only want to know that whether data is available for any specific date or not.If there are more than one data with the same date, i do not want to fetch all the data.I try to use
LIMIT 0,1 in where clause but it means it will fetch total 1 data for the given date range.
So please tell me the way to fetch data between a date range with 1 data for particular date.
Thanks.
Very simple example:
CREATE TABLE(
name,
date
);
insert into events values ("foo", "2008-01-01");
insert into events values ("bar", "2008-01-01");
insert into events values ("goo", "2009-01-01");
insert into events values ("gai", "2009-01-01");
select max(name), date from events group by date;
Output:
foo|2008-01-01
goo|2009-01-01
See How to select the first/least/max row per group in SQL

Filtering table rows with higher date than provided

I'm currently trying to do it that way:
// Creating date object
$date = new Zend_Date();
// Adding to it 4 weeks
$date->add('4', Zend_Date::WEEK); // it's expire day
// Getting date in integer(i guess it's unix timestamp yes?)
$date->get();
// Saving it to Mysql in field 'expire' with type Varchar
Then, when needed to get rows, that have date bigger(that haven't yet expired), than current I just add to SQL a simple statement WHERE expire >= $current_date.
Or there is better way to do it? Or how it happens usually?
I would recommend using the native MySQL DATETIME column in your table. This is how you'd retrieve the date for MySQL:
$date->get('yyyy-MM-dd HH:mm:ss');