I have a column with dates formatted as decimals, for example: 20,210,830. I want to convert this number to date format as 08/30/2021 I have tried to use convert and the database shoots me an error that convert is not a valid function. Cast seems to work but, only returns a null value every time. This statement will validate: This
Tag: casting
Lower bound for Postgres integer type out of range?
Per Postgres documentation, an integer type is defined between -2147483648 and +2147483647. I thought that these boundaries were inclusive, but if I try: an Integer out of range error is raised. The upper bound seems to be casted properly: And if I increase the lower bound by one it works fine as well: The same result is applied to smallint.
Summation of 2 floating point values gives incorrect result with higher precision
The sum of 2 floating values in postgres gives the result with higher precision. Expected: Actual: The result is having higher precision than expected. The same operation with different set of inputs behaves differently. Here I have reduced the problem statement by finding the 2 numbers for which the issue exists. The actual problem is when I do this on
Order of CAST() and COALESCE() matters in MariaDB
I have a strange problem: There is a price in a JSON column in a table and the following statements give different results while they should give the same thing: Just to check I also added a JSON_EXTRACT(item.price_details, “$.shipping.price”) AS shipprice Result: MariaDB version: mariadb Ver 15.1 Distrib 10.3.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 DB Fiddle (I couldn’t use
T-SQL :: Error converting data type varchar to numeric when changing 1 to 0.5
I’m writing a complex T-SQL query with CASE that will help me calculate how much time it will take me to migrate databases based on the size of each database: All good, it works when I set 1 hour of work for every database which has less then 100.00 MB. Also all other values are summed and in the Hours
Convert character to number, like +00005 to 5
We have the fixed format data and it has the number with plus/minus sign, like +00005 or -00005. We’d like to convert it to number but Redshift seems not to allow implicit conversion. So, I temporarily use to_number(replace(<numbercolumn>, ‘+’, ”),’99999′) But I guess there should be more better solutions. Anyone know more smart way, your advice would be highly appreciated.
What is the type casting hierarchy in mysql?
Taking the following example: If I only include the first select statement in the cte, the type will be int. If I include the first and second, the type will be DECIMAL, and if I include all three, the type will be cast to VARCHAR (regardless of position of the three statements). How does mysql determine which type to cast
datetime.datetime conversion to datetime
I have defined a column in SQL Server as ldate with datetime data type and accepting null values. I’m trying to send data from my local machine using python and pyodbc. I have date like 20-01-2015 in string format. When I try to send data it throws an error: pyodbc.DataError: (‘22007’, ‘[22007] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed
replace value with 1 and apply SUM method in one query SQL
I need to replace the value in column imp from 1-0 to 1 and sum it up. Column imp is a STRING, so it also needs to be converted to INT. Each line represents the record so I need to sum up imp and group by another column (in order to get the number of records for a specific Advertiser)
Error converting data type nvarchar to numeric convert/cast
I suspect this has to do with reporting ClientName, which is a nvarchar data type. AUMid is nchar. I’m not sure how to work around this without changing the data types (which I prefer not to). I need to display Clients.ClientName. It is linked to the AUM table via AUM.AUMid. Removing SUM(AUM.AUM * AUM.ManagementFee) AS Management_Fee allows the query to