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
Related
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 months ago.
Improve this question
Well, I have a problem with sending data. There are three stations, all of which work on-site on an ongoing basis. I checked the system settings and settings and one of the stations was updated to the 21H2 version (I set everything up as it is at the station where it works). Unfortunately, this option did not help. I also turned off the error on the server by setting it on the station.
I'm adding an error dump
I think SQL Server assumes another format than the one you
intended and another value causes the error.
Use CONVERT(smalldatetime, YourColumn, 101) to force format mm/dd/yyyy, or
use CONVERT(smalldatetime, YourColumn, 103) to force dd/mm/yyyy.
To prevent this in the future:
Always store dates as a datetime or smalldatetime column.
When you have to convert character data to datetime, always use one of
the unambiguous formats:
For date only: yyyymmdd
For date plus time: yyyy-mm-ddThh:mm:ss.mmm (where the optional .mmm
part denotes the milliseconds)
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 wanted to convert my string 'Jan 22,2021' to date 01/22/2021.
I used TO_DATE() function for it but it does not work. it shows invalid string.
What changes I must do to get desired result
Did you try with a style parameter?
select to_date( 'Jan 22,2021', 'Mon DD,YYYY')
from dual;
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
Trying to select data only between a range.
select ITM_NBR,
TOT_IVO_ITM_QTY,
Count(*)
FROM dataset
WHERE
bus_dt BETWEEN '2-14-2020' AND '2-15-2021'
Failed conversion to numeric value. Tried without single ticks and it returned zero rows which makes me believe that the column is stored as a VARCHAR. Tried Casting the bus_dt column into a date format.
CAST(bus_dt AS DATE FORMAT 'mm/dd/yyyy') BETWEEN 2/14/2020 AND 2/15/2021
Again failed conversion.
I feel as if I’ve tried every combination and can’t get anything to work of casting and putting the date values in yyyy-mm-dd, mm/dd/yyyy, etc. formats.
And also when I HELP VIEW to see the column type I get “?”.
Kind of at a loss right now.
After I thought I tried everything I figured it out....
I was not formatting my date literals correctly .... faceplam
DATE'yyyy-mm-dd'....
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.
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)