Date conversions in SQL [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How to convert MM/DD/YY (for example: 12/23/14) to YYYY-MM-DD (for example: 2014-12-23) in MS SQL Server 2012?

CONVERT(VARCHAR(10),GETDATE(),126)

If you're looking to load the data into a column that is the Date datatype, then you can cast a string as a date:
CAST('12/23/14' AS DATE)

Related

SQL: how to convert timestamp to datetime? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
I need to convert "2022-04-29T07:20:32.727Z" to "2022-04-29 07:20:32".
I am quite new to SQL and haven't found the solution.
You can use cast()
select cast('2022-04-29T07:20:32.727Z' as datetime)
Output
2022-04-29 07:20:32.727

Change format and remove nanoseconds from Time in SSMS 18 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am working on a table that will display employees' Shift Start and End times. Also, it will have the employees' Punch In and Punch Out times.
Is there a way to remove the nanoseconds and change the 24-hour Time format to AM/PM? I'm using Microsoft SQL Server Management Studio 18.
Yes, you can format your datetime column using the format function:
SELECT FORMAT(ShiftStartDate, 'yyyy-MM-dd hh:mm:ss tt')
FROM yourtable

convert a string (43677) to date format in SQL(Redshift) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How to convert a string (43677) to date in SQL(Redshift)? (I'm trying to convert strings, which are number format of any particular date in excel)
It depends what day you want, but I think:
select dateadd(day, 43677, '1899-12-30')
This interprets the value as an Excel date. It produce 2019-07-31.

Sql code to create the Mirror image of the string in Oracle sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Team,
I need a sql query or function which will create the mirror image of string.
Thanks
Rajeev
If "mirror" is reversed text use:
SELECT REVERSE('my_text') FROM dual;
EDIT:
SqlFiddleDemo
SELECT t
,REVERSE(t) AS Mirror1
,TRANSLATE(t, 'abcdefghijklmnopqrstuvwxyz',N'ɐqɔpǝɟbɥıظʞןɯuodbɹsʇnʌʍxʎz') AS Mirror2
,TRANSLATE(REVERSE(t), 'abcdefghijklmnopqrstuvwxyz',N'ɐqɔpǝɟbɥıظʞןɯuodbɹsʇnʌʍxʎz') AS Mirror3
FROM tab;

drop everything to the right of a hyphen in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am using Oracle SQL developer 2012. My data looks like 'valueA-valueB'. I want to strip the content after - and populate with rest.
You can use a combination of substr and instr:
SELECT SUBSTR(my_column, 1, INSTR(my_column, '-') - 1)
FROM my_table