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 6 years ago.
Improve this question
Where is the problem with my sql command?
select REPLACE(CONVERT(varchar, CAST(price AS money), 1),'.','.') as price
output :
price
-----
145,000,00
I want output like this
price
-----
145.000,00
Formatting results is usually best left for the front end.
Having said that, with SQL Server 2016, use the format function with an appropriate locale:
declare #m money = 145000
select format (#m, '#,###.00', 'DE-de')
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 1 year ago.
Improve this question
I have a decimal hour (logged_hours) column and its value in my table. I want to calculate this decimal hour value into minutes in SQL Server 2012.
logged_hours
------------
08.0000
09.0000
12.0000
You can multiply by 60:
select logged_hours * 60 as logged_minutes
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
Ex: if we concatenate 12345 and 31-dec-2019 If we concatenate using & symbol we get 1234531-dec-19 in Ms access but if we do same in excel we get 1234543830 so to get the result as we get in excel what is the query to get this.
You can use the CLng function to convert the date field to a number:
SELECT NumberField, DateField,
[NumberField] & CLng([DateField]) AS CombinedData
FROM Table4;
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
Say I am trying to sort through and I want to see the dates 10/22/2020, 10/23/2020, 10/24/2020, and/or 5/5/2020. How could I do this? When I run with the following code it will not work.
AND appointmentsTable.scheduledDate = #startDate
AND appointmentsTable.scheduledDate = #date2
AND appointmentsTable.scheduledDate = #date3
AND appointmentsTable.scheduledDate = #endDate
Screenshot of query I currently have
You would convert to a date:
order by convert(date, appointmentdate, 101)
But you should fix your data model so dates are stored as dates.
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 have a column in which i have 'goswara no. 21/1980' i need only 21 and year from date column like this col gr=21/year(date) through sql2005 query
http://sqlfiddle.com/#!6/bf991/6
something like this?
select
right(columnname,4) as year ,
SUBSTRING ( columnname ,len(columnname) - 6 ,2 ) as result
from test
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 8 years ago.
Improve this question
I have a column with datatype decimal(3,0) null
Column has values like 80, 90, 100
To this decimal value column, I need to append an % sign.
I need to cast the decimal value to nvarchar.
Expected output is 80%, 90%, 100%
SELECT CAST(YourColumn AS VARCHAR(3)) + '%'
FROM YourTable