Date format not consistent for a particular column in .csv file using app engine in peoplesoft - sql

I am generating a report in .csv format. The file is having date fields. In those date fields, the date is coming in "dd/mm/yyyy" format and "dd-mm-yyyy format".
I have used to_char(date,'DD-MM-YYYY') for all date fields. Still I am not getting consistent date format. Please help me resolve this issue.

you can retrieve a date type from the DB and use a string field in the output file. In peoplecode use: DateToLocalizedString
PeopleSoft Documentation

Related

Importing CSV file but getting timestamp error

I'm trying to import CSV files into BigQuery and on any of the hourly reports I attempt to upload it gives the code
Error while reading data, error message: Could not parse 4/12/2016 12:00:00 AM as TIMESTAMP for field SleepDay (position 1) starting at location 65 with message Invalid time zone: AM
I get that the format is trying to use AM as a timezone and causing an error but I'm not sure how best to work around it. All of the hourly entries will have AM or PM after the date-time and that will be thousands of entries.
I'm using the autodetect for my schema and I believe that's where the issue is coming up, but I'm not sure what to put in the edit as text schema option to fix it
To successfully parse an imported string to timestamp in Bigquery, the string must be in the ISO 8601 format.
YYYY-MM-DDThh:mm:ss.sss
If your source data is not available in this format, then try the below approach.
Import the CSV into a temporary table by providing explicit schema, where timestamp fields are strings.
2. Select the data from the created temporary table, use the BigQuery PARSE_TIMESTAMP function as specified below and write to the permanent table.
INSERT INTO `example_project.example_dataset.permanent_table`
SELECT
PARSE_TIMESTAMP('%m/%d/%Y %H:%M:%S %p',time_stamp) as time_stamp,
value
FROM `example_project.example_dataset.temporary_table`;

How to solve error gdk-05030 when importing csv data in SQL Developer

I have a problem importing a CSV file using SQL Developer. I created a table to import a 'date' data by using the code below
CREATE TABLE DEPARTMENT (
DATECOLUMN DATE
);
I imported the CSV by right clicking and so on.
Interestingly, the CSV 'date' data has a format of 'YYYY-MM-DD', but when loaded in SQL developer (preview, before importing), it took the format of 'MM/DD/YYYY'.
I believe this is the problem, because when trying to import, it returned error "gdk-05030", meaning the data contains more than needed (to fit the format).
To me, it looks as follows:
date format in a CSV file is yyyy-mm-dd (as you said)
when you queried the table after insert, you found out that values look differently - mm/dd/yyyy
it is because current settings use that date format. If you want to change it, run
alter session set nls_date_format = 'yyyy-mm-dd';
and then select rows from the table.
alternatively, go to SQL Developer's Preferences, and set desired date format in its [Database - NLS] section.

Import/convert my date column from Excel into a datetime datatype in SQL Server?

I am importing an Excel file in CSV format. The file has 1,048,576 rows.
So far I have not been able to import the file with datetime datatype or convert/cast the columns with dates to datetime data types. I can only import the date column as a nvarchar, varchar or sql variant. The only time I can convert the column is if the file is under 71000 rows. Otherwise I get an error that the conversion from string is out of range or failed. (Please see below for pictures and more detail)
I have tried the following
Casting or converting the columns
Changing the data type via the table design
Importing with date time datatype
Copy and paste the data to a datetime column
Checking and converting the date column in excel, before importing
Batch Inserting the document
Importing as a text file
Removing null columns in the excel file
Importing as non string variable
Creating a temporary table
Making temporary variables with datetime data types
Notes
I am using the developer edition of sql server
I am trying to get the date columns(transaction_date, date_created) into a
date time datatype, I can only have them as a narvchar datatype currently
How I Import The CSV File
Right clicking database, clicking task and import flat file
Error Messages
Error message when trying to convert via table design
Error message when importing csv file to sql server
Sample of The CSV File
Sample of the CSV File Showing About 10 Rows
Database Schema
Brief Synopsis of Desired Database, Trying to Get Date Columns to DateTime Data type
Function SQLDate(d)
SQLDate = WorksheetFunction.Text(d, "yyyy-mm-dd hh:MM:ss")
End Function
Note: "d" refers to date field.
Alternatively, you could convert Excel data to string:
TEXT(d,"dd mmmm yyyy hh:mm:ss")
Then convert as req. from within SQL. For further clarity in this regard - see screenshot below.
Citation: Thanks to H Javed

Get Current Date from TXT/LOG File

Just started using LogParser recently, and I'm new to SQL queries.
I'm trying to get LogParser to find a log file with today's date, then outputting specific contents of the file into a text document. For example:
Select Text INTO D:\LogParser\output\BlahYYYY-MM-DD.txt
From 'C:\Logs\BlahYYYY-MM-DDBlah.log'
where Text like '%exception%'
How do I get my query to search for today's date in the file name, while keeping the YYYY-MM-DD format, and output to a text file with the same date and format?
Unfortunately there is no way to use functions in the FROM (nor in the INTO) clause.
If you can get the date from some other means, you could save the query to a file, specify e.g. %MYDATE% instead of the date, and then run the query specifying the parameter values as follows:
LogParser file:myQuery.sql?MYDATE=...

How to change the date format when the file is spooled in oracle

Currently i'm generating a export where the date format is actually dd/mm/yyyy but when i spool it and see it is coming as dd/mmm/yyyy in a readable format
For example if the date in my real file is 06/10/2014 in the spool it automatically is coming 06-Oct-2014. But i don't want this format. How to retain the original one?
You can convert your date column to char representation before exporting
to_char(date_column, 'dd/mm/yyyy')
There is no such thing as an original date format. Oracle stores dates without any format. When you're spooling your data, you either have to specifically indicate a format or Oracle uses a system default format.
So, if you consistantly want the format to be dd/mm/yyyy then you could change the default format for just a session with
alter session set nls_date_format = 'dd/mm/yyyy'