SSconvert convets date to YYYY-MM-DD irrespective of xlsx date format - ssconvert

I am using ssconvert to convert xlsx to csv. One of the column has date field so when I convert it into csv date column value has converted into YYYY-MM-DD
Input:
Name Date
Test 05/08/2021
Command:
ssconvert test.xlsx test.csv
Output:
Name,Date
Test,2021-08-05
Expected Output:
Name,Date
Test,05/08/2021

Try to use sed:
sed -i -Ee 's#([0-9]{4})-([0-9]{2})-([0-9]{2})#\3/\2/\1#g' test.csv

This should be working:
ssconvert --export-type=Gnumeric_stf:stf_assistant -O "format=preserve" test.xlsx test.csv

Related

Date format in BigQuery

Edited: Want to convert the format.
I am kinda new in BigQuery, recently I was working on a project. I want to convert above type of format into yyyy/mm/dd format. How will I do that?
You can combine PARSE_DATE with FORMAT_DATE to get the desired output:
SELECT FORMAT_DATE("%Y/%m/%d",PARSE_DATE("%B %d, %Y","June 10, 2014")) AS date_str
PARSE_DATE will parse the provided string into a DATE type value in BQ format (YYYY-MM-DD) and then FORMAT_DATE will format this DATE to a string with the desired output.
In case someone is wondering how to convert the whole column;
FORMAT_DATE("%Y/%m/%d",PARSE_DATE("%B %d, %Y",ColumnName)) as DesiredColumnName

Convert dd-mmm-yyyy to yyyy-mm-dd in sparksql

I have a date value in this format 'dd-mmm-yyyy'(Example31-Mar-2020) in a glue table. I need to transform this to 'yyyy-mm-dd' (output:2020-03-31) format using sparkSql.
I have tried. "date_format(reference_line_attribute3, 'yyyy-mm-dd')" but this just gives null as output.
Please help.
Thank you
This should do the trick
df.withColumn("newDate",
date_format(
to_date($"reference_line_attribute3", "dd-MMM-yyyy"),
"yyyy-MM-dd"))
Output
+-------------------------+----------+
|reference_line_attribute3| newDate|
+-------------------------+----------+
| 31-Mar-2020|2020-03-31|
+-------------------------+----------+

Unable to parse date in Pig

I'm unable to parse date in pig.
Date format is Mon, 10/11/10 01:02 PM
I load data using the following command:
data = load 'CampaignData.csv' using PigStorage(';');
Next I generate the date column as a chararray using the following command:-
date_data = foreach data generate (chararray) $272 as dates;
when I dump date_data I get the following in output:
Mon
How to get the complete date?
You don't need $272 to convert date provided to datetime object. You can simply follow this :
date_data = foreach data generate ToDate($273, ' MM/dd/yy hh:mm aaa');
Just make sure $273 is chararray and there is space before data format string specified in ToDate function above. Space is required only to make sure format string looks exactly as data that would be present after parsing row using comma delimiter.

Hive - UNIX_TIMESTAMP Quandary

Here is my 1 line of data (for brevity):
73831 12/26/2014 1:00:00 AM 0.3220
The 2nd column is the time column which is in string format. I'm using this hive query:
select col2, UNIX_TIMESTAMP(col2,'MM/DD/YYYY hh:mm:ss aaa') from Table
Here is what I get: 1388296800
However, when I check with, http://www.epochconverter.com/ and also from_unixtime(1388296800), I get a different date.
Is there something wrong with my format / pattern string I enter into UNIX_TIMESTAMP in Hive?
Your date format symbols need to conform to those in the Java SimpleDateFormat documentation.
For your date it looks like you want MM/dd/yyyy HH:mm:ss aa.

convert oracle varchar date read into variable to linux date

I am reading dates 'VARCHAR(14)' from an oracle table with a sql query in BASH, into a variable. I want to compare that date (eg. 20140611120520) with the system date. If the variable date is 15 minutes or older than the system date I need to kick off another procedure.
This is my query:
Get_einlag_time=`sqlplus ips_osmr/ips_osmr << eof | awk ' $1 == "This" { print $2 } '
select 'This ' || DZ_EINLAG
from LAG_SPI
where C_STATUS like '%E%' ;
eof
`
$Get_einlag_time - may result in more than one date seperated by a space (eg. 20140411141231 20140605075650)
I then read the dates one by one fom this variable with a For GET_TIME in $Get_einlag_time loop, comparing them with the system date.
Now I have this date value in $GET_TIME but I cannot do a date comparison as I get 'invalid date' from this variable.
This was my latest try in convertion before I gave up to ask for expert advice :-)
echo "time read from Get_einlag_time is $GET_TIME"
EINLAG_TIME=$(date +%Y%m%d -d "$GET_TIME")
EINLAG_CHK=$(date -d "$EINLAG_TIME+15 Minutes" +%Y%m%d%H%M%S)
EINLAG_SEC=$(date -d "$EINLAG_TIME" +%s)
COMPARE_TIME=$(date +%Y%m%d%H%M%S)
COMP_SEC=$(date +%s)
The $EINLAG_SEC converted %s gives me an extremely huge and unlikely value.
Perhaps you'd do it like this:
SELECT CAST ('This ' AS TIMESTAMP) || DZ_EINLAG AS This
from LAG_SPI
where C_STATUS like '%E%' ;
Not sure if the syntax works but you get the idea.
If it doesn't work you might as well refer to here for getting unix timestamps properly:
Convert timestamp datatype into unix timestamp Oracle
Actual probable solution:
GET_TIME=${R:0:4}/${R:4:2}/${R:6:2}\ ${R:8:2}:${R:10:2}:${R:12:2} ## Where R is like 20140411141231