How to convert a particular column in table from hex to decimal in sql [closed] - mysql

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 3 years ago.
Improve this question
I have a query of 15 columns and one of them has a hexadecimal value, i wanted to convert it to decimal or int. How can i do it

You can also use
SELECT CONVERT(INT, *rowName*) AS Converted *rowName*;
EDIT:
CONVERT works with MS SQL
CONV(num, base, to) is for MySQL
SELECT CONV(*rowName*,16,10) AS Converted *rowName*;

use CONV()
CONV(num , from_base , to_base );
select SELECT CONV('b',16,10)'Hexadecimal to Decimal'

Related

Returning a Decimal Value in a stored procedure [closed]

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 2 years ago.
Improve this question
I am trying to return a value that is a sum of decimal value in SQL Server 2008. I've tried using convert but it doesn't help. Here is the relevant code snips:
#ActivitySum dec (18,2) OUTPUT)
AS
SELECT
#DistinctActivities = COUNT(DISTINCT [Activities].[Activity ID]),
#Activities = COUNT([Activities].[Performer Activity ID]),
#ActivitySum = SUM(Activities.[Score])
FROM
Scenes
INNER JOIN
Every time I execute, if the sum of score has value after the decimal point, the value gets rounded to a whole number.
Any thoughts or solutions?

My mysql queried returned with wrong data [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 3 years ago.
Improve this question
SELECT * FROM gbtss.weighing where indate between '04/02/2019' and '04/08/2019';
I want to retrieve data data between these two dates, but the above command doesn't work in mysql workbench.
Use valid MySQL date literals:
SELECT *
FROM gbtss.weighing
WHERE indate BETWEEN '2019-02-04' AND '2019-08-04';
I assume here that 04/08/2018 means the fourth of August, 2018. If it means the either of April, 2018, then use '2019-04-08' instead.
See the MySQL documentation for valid date literal formats.
If you are actually storing plain text into indate, then you would also have to do an additional step of calling STR_TO_DATE on that column:
SELECT *
FROM gbtss.weighing
WHERE STR_TO_DATE(indate, '%d/%M/%Y') BETWEEN '2019-02-04' AND '2019-08-04';

Integer to Datetime SQL [closed]

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 5 years ago.
Improve this question
I need convert this integer "1469416462" to datetime in format dd-mm-yyyy hh:mm:ss . Any ideas?
My Intent:
select CONVERT (datetime,1469416462)
The value 1469416462 looks like a Unix-Timestamp.
Unix-Timestamp: Seconds since 1.1.1970
So the solution would be easy like:
For MySQL:
SELECT from_unixtime(1469416462)

Convert mm/dd/yyyy string into timestamp in MySQL [closed]

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 6 years ago.
Improve this question
I have a column in a MySQL table where dates are stored as a mm/dd/yyyy string. I need to preserve that column as is, so I have added a new column where I want to store that date as a timestamp. What would the query look like to take column a and convert it to a timestamp and put it into the new column b?
you can use STR_TO_DATE to convert your string like
select str_to_date('02/22/2013','%m/%d/%Y');
UPDATE YourTable set newCol = str_to_date(yourOldCol,'%m/%d/%Y');

mysql str to time [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
Looking at the time functions but need help to convert time from
"18:00:00" to 6 PM in the SQL language.
You can convert the string to a time and then convert the value to a string using date_format():
select date_format(cast('18:00:00' as time), '%h %p')