Convert Hex to String in Teradata - hex

I'am trying to convert a hexadicimal to string in Teradata SQL
ex: convert_hex_to_string('616263')='abc'
Is there away to do this?
Thanks

Related

Snowflake GMT String to Date Conversion

We receive a string '2019-11-30T18:00:00GMT-06:00' in the JSON file and this need to be converted to timestamp to load into the timestamp column in the snowflake. I tried multiple options convert_timezone,to_timestamp etc, however in vain, Can you please let me know how i represent this string (2019-11-30T18:00:00GMT-06:00) in data format for comversion.
Thanks !
Leveraging a more Snowflake way to do this, you'd want to run something like this:
SELECT TO_TIMESTAMP('2019-11-30T18:00:00GMT-06:00','YYYY-MM-DDTHH:MI:SSGMT-TZH:TZM');
The output of this will be the date/time of your account default along with the timezone offset that goes along with that.
Please try the below mentioned approach
if your table is create as below
CREATE TABLE TIMESTAMP_TEST(DATE TIMESTAMP);
Insert the value as
INSERT INTO TIMESTAMP_TEST SELECT REPLACE(REPLACE('2019-11-30T18:00:00GMT-06:00','GMT'),'T',' ') FROM DUAL
Thanks

Inserting SAS datetime into Teradata using proc sql

I have a SAS datetime stored in a macro variable and try to write that into a timestamp column in teradata using proc sql. E.g. I can write that into a string column with %BQUOTE('&macrovariable') and it returns 14APR2020:06:47:20. But I am failing to convert that into a timestamp and write into timestamp field in teradata. Cast as timestamp did also not work :( It returns ERROR: Teradata execute: Invalid timestamp.
My Code:
INSERT INTO MYTABLEWITHDATETIMEFIELD
VALUES (
%BQUOTE('&macrovariable')
)
Could you help me out? THANKS!
Best regards
Flo

Error during compare date format in sqlite query

I was writing an application on c#, which is save DateTime to the Text field in the database.
Format of date is:
'1/15/2020 14:48:44', '2/11/2020 12:53:59' and etc
Now I want to get records with SQL query by the last few days.
I understand that I need convert text to date, and compare. But SQL query return 0 results. My query is:
select * from LogRootProcessing where strftime(dateparsing) < strftime('%MM/%DD/%YYYY %HH:%MM:%SS','2/11/2020 12:53:59')
Could you please advise how to fix the query?
Thanks in advance.

Convert integer column to date column using sqlite query

I am using SQLite.
In my database, I have a integer column value like 20050819. I would like to convert this as date column as like 2005-08-19.
I can achieve my requirement when using the function CONVERT(columnName, DATETIME) in MySQL server. But I need the same result in SQLite.
Is this possible in SQLite query?
You basically have to break apart the date:
select printf('%4d-%02.2d-%02.2d',
columnname/10000, columnname%10000/100, columnname%100)
from tablename;
P.S.
If you have the choice, you will be far better off storing the date in ISO standard format ('YYYY-MM-DD') in the database in the first place.

Storing French (decimal values) in database?

I have my form set in french as well, and it automatically changes the text format to use ','. However When I try to insert my values into the database it says cannot convert nvarchar to decimal?
Worst case, Is there a way I can disable the numbers from changing to use ',' and just use '.' always regardless what language it is?
My working language is vb.net
Thanks,
Robert
If you're passing the values down to the database as nvarchar then you'll need to have converted this to a string using yourDecimalValue.ToString(Globalization.CultureInfo.InvariantCulture) or similar. SQL Server will always expect a decimal to be in 1.23 format - you can imagine the trouble that would result if queries including WHERE myvalue IN (1,25, 1,33, 1,45) were submitted!

Resources