PHPExcel expects date format d/m/y, but m/d/y entered. How to set PHPExcel Reader object to use custom date format for conversions - date

I need to read an excel spreadsheet with date format m/d/y into database. However, PHPExcel is outputting the wrong date because it thinks the date format is d/m/y.
How can I tell PHPExcel reader object to use the format m/d/y?

If the date is simply a string in the excel file, then you can use the standard PHP functions for string to date conversion (either strtotime() or DateTime objects). If the date is stored as an Excel timestamp, then you can use the PHPExcel built-in functions (PHPExcel_Shared_Date::ExcelToPHP() or PHPExcel_Shared_Date::ExcelToPHPObject()) to convert from the Excel timestamp value to a PHP/Unix timestamp or DateTime object, and then use the standard PHP date functions or DateTime methods to format it however you wish.

For clarity if other people encounter this problem:
Spreadsheet contains date 02/04/2014
You/Client/Boss entered date to be: m/d/y or February 4th, 2014
PHPExcel sees it as: d/m/y or April 2nd, 2014
The solution is to avoid the situation altogether by using the correct date formatting when the spreadsheet is created or use general formatting instead.
Q) What do I do if my client provided the spreadsheet to me?
A) Search for an entire day for a solution until you come to the same conclusion as I did or you can save yourself time and ask the client to send you another spreadsheet with the correct formatting.

Related

SQLite Convert to SQLite Datetime Format from ANY datetime format

Coming out of an Oracle background converting dates from any format to any format is really easy.
How is this done in SQLite? I've searched and searched for answers and most of the answers simply say... Save your date/strings in SQLite in one single format which is YYYY-MM-DD HH:MM:SS.SSS. This seems rigid to me.
I don't have that luxury as my data is stored in this format DD/MM/YYYY HH:MI:SS am ex. 3/7/2020 8:02:31 AM.
NOTE: For single days/months my date values do not contain leading zeros and my time is NOT in military time.
How do I tell SQLite what my date format is so that I can correctly convert my stored dates to SQLite datetime formats?
Convert from SQLite Date Format to Oracle Date Example:
In Oracle I would simply use the to_date function like so
to_date('2019-03-07 15:39:34', 'YYYY-MM-DD HH24:MI:SS')
All one needs to do is to tell the function what the date format is... and then it spits out a date.... easy peasy. What this example does is convert a SQLite date formated string to a date that Oracle recognizes as a date. It doesn't matter what the format is in as I tell the function what format to expect.
How do I Convert Dates in SQLite from any format to the SQLite Format?
Converting from SQLite's date format string to ANY date is easy as there are functions built in that do this easily... but how to do this the other way round?

Format to enter a Date in Google Forms

I have a drop-down list of dates I want users of a form to select from. I have tried mm/dd//yy, mm/dd/yyyy, yyyy-mm-dd, yyyy/mm/dd and MMM-DD-YYY, but the data that ends up in the Sheet is always 12/31/1969 (25568.6666666667 if I change the display format). What format can I use to get a date successfully imported?
The answer in this thread didn't work for me: What format is required to import a date into google spreadsheet
The format mm/dd/yyyy works; I had a problem in the naming of the columns of the spreadsheet which was the source of the problem.

Import text file with ISO 8601 date/time values (2014-07-02T16:09:49-07:00)

When importing a text file into Access 2007 with date/time values like
2014-07-02T16:09:49-07:00
Access is unable to convert to date and shows the same as text. How do I convert the same in to date/time in Access?
You will probably need to import the ISO 8601 date/time values into a Text field, then use an Update query to convert those string values and write them to a Date/Time field. The question
Parsing an ISO8601 date/time (including TimeZone) in Excel
has several answers that include VBA functions you might be able to adapt depending on your specific requirements (and possibly some slight differences in date handling between Excel and Access).

Formatting date like medium date SQLite

How to format date in SQLite to get like 10-Jan-2014. What formatting string I need.
I have seen this SQLite date formatting and other questions but did not find my answer.
The given link formats the date to only numeric like 2014-01-10 etc.
Any one know?
Month names are not supported in SQLite.
You can use a lookup table to make and get your desired format with month names directly from query.
You can also write your own formatting function in your programming language.

Date Column Split in Talend

So I have one big file (13 million rows) and date formatted as:
2009-04-08T01:57:47Z. Now I would like to split it into 2 columns now,
one with just date as dd-MM-yyyy and other with time only hh:MM.
How do I do it?
You can simply use tMap and parseDate/formatDate to do what you want. It is neither necessary nor recommended to implement your own date parsing logic with regexes.
First of all, parse the timestamp using the format yyyy-MM-dd'T'HH:mm:ss'Z'. Then you can use the parsed Date to output the formatted date and time information you want:
dd-MM-yyyy for the date
HH:mm for the time (Note: you mixed up the case in your question, MM stands for the month)
If you put that logic into a tMap:
you will get the following:
Input:
timestamp 2009-04-08T01:57:47Z
Output:
date 08-04-2009
time 01:57
NOTE
Note that when you parse the timestamp with the mentioned format string (yyyy-MM-dd'T'HH:mm:ss'Z'), the time zone information is not parsed (having 'Z' as a literal). Since many applications do not properly set the time zone information anyway but always use 'Z' instead, so this can be safely ignored in most cases.
If you need proper time zone handling and by any chance are able to use Java 7, you may use yyyy-MM-dd'T'HH:mm:ssXXX instead to parse your timestamp.
I'm guessing Talend is falling over on the T and Z part of your date time stamp but this is easily resolved.
As your date time stamp is in a regular pattern we can easily extract the date and time from it with a tExtractRegexFields component.
You'll want to use "^([0-9]{4}-[0-9]{2}-[0-9]{2})T([0-9]{2}:[0-9]{2}):[0-9]{2}Z" as your regex which will capture the date in yyyy-MM-dd format and the time as mm:HH (you'll want to replace the date time field with a date field and a time field in the schema).
Then to format your date to your required format you'll want to use a tMap and use TalendDate.formatDate("dd-MM-yyyy",TalendDate.parseDate("yyyy-MM-dd",row7.date)) to return a string in the dd-MM-yyyy format.