SQL date conversion to written date - sql

Hi everyone I have a date in the format DD/MM/YYYY how do I convert it to the newDate format displayed below?
Date |Newdate type
05/02/2017|Sunday 5 March 2017
04/02/2017|Saturday 4 March 2017
USING a SQL front end based on Microsoft jet

managed to find an answer
https://msdn.microsoft.com/en-us/library/ee634398.aspx
FORMAT(column,'dddd dd MMMM yyyy ')

Related

How to convert a datetime ''May 30 2022 9:30PM" to this "2022-05-30 21:30:00" in Snowflake SQL?

I have a date column in text format of "May 30 2022 9:30PM" and it needs to convert to "2022-05-30 21:30:00" in Snowflake SQL
I tried below SQL and its not working.
SELECT cast('May 30 2022 9:30PM' as datetime);
For Snowflake, try the following:
select to_timestamp_ntz('May 30 2022 9:30PM', 'MON DD YYYY HH12:MIAM');
Reference:
https://docs.snowflake.com/en/sql-reference/functions-conversion.html

How to convert "Wed Jan 26 2022" to date in sql?

I have varchar like this "Wed Jan 26 2022"
I need to convert this to date in sql. How can i do this
for Sql Server:
convert(date, substring('Wed Jan 26 2022',5,11),9)
we ignore the Day name (superfluous), and convert the rest using format 9 indicating Mon dd yyyy format.
SQL*plus server (Here's my code) -
If I am right, you want such type of string which is an invalid one to convert that into a valid one so that you can store valid data into the database. then this code you can use->
SELECT TO_DATE('WED JAN 26 2022','DY MON DD YYYY')FROM DUAL;
(Explanation)->
Code will convert invalid date datatype to a valid date data type which is used in Oracle(SQL).
DY = Abbreviated Week Day
DD = Month day indicator
MON = Abbreviated month
YYYY = Four-digit year indicator

Dremio date conversation

How to convert date field "Dec 1 2018 6:38PM" to dd-mm-yyyy (01-12-2018)` in Dremio?
select to_timestamp('Dec 1 2018 6:38PM','mon dd yyyy hh:miAM')
Date/Time formats here: https://docs.dremio.com/sql-reference/sql-functions/datetime-formats.html

Convert Date/Time to Date/Military Time

How can I convert a varchar column in SQL Server 2008 within a table of 1 million+ records containing date/time to the following format: MM/DD/YYYY HH24:MI:SS
Example:
'Feb 14 2017 3:00PM' converted to '02/14/2017 15:00:00'
'Feb 18 2017 10:03AM' converted to '02/18/2017 10:03:00'
The date/time column header = ACTION_TM
Please note the double space between the year and time in the first example vs single space of the second. '2017 3:00' vs '2017 10:03'.
Thank you in advance
https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql
sample ... varchar(20) for length... and convert to 20 for format or any desired format.
select convert(varchar(20),getdate(),20)
however in your case you'll have to convert your column into a valid date so should be
select convert(varchar(20),cast('Feb 14 2017 3:00PM' as datetime),20)
select convert(varchar(20),cast('Feb 18 2017 10:03AM' as datetime),20)
the untidy way of doing it is
select convert(varchar(10),cast('Feb 14 2017 3:00PM' as datetime),101) + ' ' + convert(varchar(112),cast('Feb 14 2017 3:00PM' as datetime),114)

Format 1800 date in SQL Server & Oracle

I have the following date in our SQL Server 2008 database: 06-24-1881 00:00:00:000 as a DOB and it's stored as datetime.
I need to copy this data into our Oracle 11g database and from my understanding Oracle does not accept milliseconds into a Datetime column. For my data after 1900 I converted the data to smalldatetime and it worked but for this piece of data, it won't convert to smalldatetime since it doesn't allow for dates prior to 1/1/1900.
How do I get many rows of data into my Oracle database?
I tried this:
left(DOB, 19) as DOB
but that rendered the data as "Jun 24 1881 12:00AM", so I tried inserting with:
to_date('Jun 24 1881 12:00AM', 'MON-DD-YYYY HH:MI:SSAM')
and that didn't work either. I am stuck and need help.
Jun 24 1881 12:00AM matches the Oracle format string MON DD YYYY HH12:MIAM. Your format mask has an added seconds :SS mask that Oracle is trying to match but not finding in the input so will throw an ORA-01861: literal does not match format string exception.
So, if the output from SQL Server is in that format then in Oracle you should be able to do:
TO_DATE( 'Jun 24 1881 12:00AM', 'MON DD YYYY HH12:MIAM' )
CONVERT(VARCHAR(20),#Date,101) will give you 06/24/1881 I am looking for code now.
REPLACE(CONVERT(VARCHAR(200),#Date,101),'/','-') + ' 00:00:00:000'
Weird I tried a bunch of the century codes with CONVERT and it worked for 101 and some others but the 113 you want failed but because you don't have minutes, hours, seconds etc. you can just take the the 101 format and manipulate the string to what you want.
DECLARE #Date DATE = '06-24-1881 00:00:00:000'
SELECT #Date
,FORMAT(#Date, 'MM-dd-yyyy HH:mm:ss')
,REPLACE(CONVERT(VARCHAR(200),#Date,101),'/','-') + ' 00:00:00:000'
Note the FORMAT(#Date, 'MM-dd-yyyy HH:mm:ss') is SQL 2012 or newer and works well.