Extract date from a string using Talend - csv

I am receiving CSV files daily which have header like
"AD PERFORMANCE REPORT (Jan 24, 2016)".
I would like to extract date from it and use it as date column using Talend.
How can I do that?

For change the format of a specicif column in other format, you can use the "tExtractRegexFields", with your regex for get just your date.
tFileInputDelimited --> tExtractRegexFields --> tMap --> tFileOutputDelimited
After get the date in your string with the 'tExtractRegexFields' component, you can specifyy the type of date in your output Schema like that :
the pattern of your date (Jan 24, 2016) is "MMM d, yyyy"
link for tExtractRegexField on Talend is here
link for a great website for test your regex is here
link for date Pattern in Jav is here

I used the following regex in tExtractRegexFields
"\(([^)]*)\)"

Related

What format does a Google Data Studio DATE field expect from the connector?

I am building a Google Data Studio connector with a field called date. The field's type is YEAR_MONTH_DAY. Now, when I return a string, for instance "2020-09-22", the field shows null as a result. What value should my connector provide to have Data Studio recognize it as a date?
"2020-09-22" is of type YEAR-MONTH-DAY, not YEAR_MONTH_DAY
Without knowing the specifics of the connector you are using:
Be careful theat your provided format matches the expected one
Read about supported Dates and times in Data Studio
If necessary, use date formatting methods like e.g. TODATE
If the DATE field you are talking about is the absolute date as mentioned here, the expected format is YYYYMMDD.
For some reason I have had to implement a workaround for this more often lately which is to create a new field in the data source and use the TODATE() function and use that new field in my dimensions on the report.
Try a formula field like:
TODATE(comp_pd_end, "%Y-%m-%d", "%Y%m%d")
The expected date format for the connector is YYYYMMDD, without any separator.
You can check the official documentation:
https://developers.google.com/datastudio/connector/reference?hl=en#semantictype

Format Date field in XAMPP SQL database to german layout (dd.mm.yyy) [duplicate]

I have a table in excel (CSV) which I am importing into phpmyadmin.
the cells show the date fine such as: 09/11/2012 0:00
The cell format is "custom"
when I import the table into phpmyadmin, all the dates turn to: 0000-00-00 00:00:00
What is the correct way to put them in excel so that I can import them into the database.
And how can I convert them to the correct format?
Format your excel dates into the format php accepts. E.g. yyyy-mm-dd h:mm:ss
In excel use the following steps:
Right click the column heading that contains the dates.
Select Format Cells
Click the "Custom" category
Paste "yyyy-mm-dd h:mm:ss" in the input box.
*. Save the document.
In php SQL query, make sure to set this column to date in anycase if php side is going to treat the date as a string.
You may use : ‘STR_TO_DATE(#date, '%Y-%c-%e %H:%i:%S')‘
I had this problem and thought I formatted them to format YYYY-MM-DD. They were displayed that way, but in the Formula bar it was still in DD/MM/YYYY format.
So I actively changed the date with:
=YEAR(A1)&"-"&IF(MONTH(A1)<10;"0";"")&MONTH(A1)&"-"&IF(DAY(A1)<10;"0";"")&DAY(A1)
And then copied the values of these cells to replace the original ones...

using excel dates for importing into phpmyadmin sql

I have a table in excel (CSV) which I am importing into phpmyadmin.
the cells show the date fine such as: 09/11/2012 0:00
The cell format is "custom"
when I import the table into phpmyadmin, all the dates turn to: 0000-00-00 00:00:00
What is the correct way to put them in excel so that I can import them into the database.
And how can I convert them to the correct format?
Format your excel dates into the format php accepts. E.g. yyyy-mm-dd h:mm:ss
In excel use the following steps:
Right click the column heading that contains the dates.
Select Format Cells
Click the "Custom" category
Paste "yyyy-mm-dd h:mm:ss" in the input box.
*. Save the document.
In php SQL query, make sure to set this column to date in anycase if php side is going to treat the date as a string.
You may use : ‘STR_TO_DATE(#date, '%Y-%c-%e %H:%i:%S')‘
I had this problem and thought I formatted them to format YYYY-MM-DD. They were displayed that way, but in the Formula bar it was still in DD/MM/YYYY format.
So I actively changed the date with:
=YEAR(A1)&"-"&IF(MONTH(A1)<10;"0";"")&MONTH(A1)&"-"&IF(DAY(A1)<10;"0";"")&DAY(A1)
And then copied the values of these cells to replace the original ones...

How to get the date value in the table in specific format?

I have one problem in my tool. I am using one MySQL table called calendar. From this table I am fetching some date values. The format of date in calendar table is yyyy-mm-dd. But in my system having dd-mmm-yy. In my c# application I fetched the date from the Calendar and If I displayed the date in c# application means date format(2012-10-05) changed to system format(05-oct-12). But I need to display in yyyy-mm-dd format. I don't know how to solve this problem.
To display DateTime in specific format, you can specify the format in .ToString() method like:
DateTime dt = DateTime.Now; //your DateTime variable
Console.WriteLine(dt.ToString("yyyy-mm-ddd"));
You may see the article: Standard Date and Time Format Strings - MSDN

excel format date for mysql

My excel sheet has the following format : dd/mm/YYYY
ex: 24/10/2010 (european format)
and my mysql needs: YYYY-mm-dd (US format)
How can I format the date in Excel to have this US format ?
I tried with cell format, but I don't have the desired format
Regards
Here's how you can find this Number format in Excel:
Go to Format Cells and then the Number tab.
Select Date
Change the Locale to English (U.K.)
The fifth item on the list (on my U.S. version of Excel) is the format you're looking for.
Hope that helps!
For the hours, minutes and second
go in the custom category and enter this :
yyyy-mm-dd hh:mm:ss
Use the text function -- assuming that the date to be converted was in cell A1, =TEXT(A1,"YYYYMMDD") will get your data into a format that mysql will understand as a date.
There are many solutions, but I reformat the dates for mysql using this formula (assuming your date is in cell E2):
=YEAR(E2)&"-"&RIGHT(TRIM(100+MONTH(E2)),2)&"-"&RIGHT(TRIM(100+DAY(E2)),2)