I am facing an issue with snowflake when converting a string to timestamp. Here is an example....
SELECT TO_TIMESTAMP('18090322033010','DDMMYYHH24MISS')
can anyone help me to convert this? the output should be 2003-09-18 22:03:3010
Appreciate your help
Why are you expecting 3010 to be seconds?
Try this:
SELECT TO_TIMESTAMP('180903220330','DDMMYYHH24MISS');
OR this:
SELECT TO_TIMESTAMP('18090322033010','DDMMYYHH24MISSFF');
Related
I have to convert "to_char(trunc(new_time(sysdate('GMT','PST' )) -1,'Mon-YY')" Oracle query into snowflake. Could anyone please help me.
Convert_timezone is the function in Snowflake that converts a timezone of a timestamp.
select convert_timezone('America/New_York', 'UTC', current_timestamp::timestamp) ;
For more information you can refer snowflake docs link
Good afternoon, all!
Trying to get temperature off a database on my SQL server stored as "78.3 F" and make it only the number "78.3". The database has this field as nvarchar. I tried:
select
Cast(Left(Paint_Environ.Booth1_Temp, Len(Paint_Environ.Booth1_Temp) - 2) As NUMERIC(4,1)) As Temp
from Paint_Environ
but get an errors saying "Error converting data type nvarchar to numeric" Is there a better way to convert nvarchar to something numeric???
Thanks in advance!
Matt
As I mentioned in the comments, your code should work with data '78.3 F'
You may try this
SELECT
CAST(REPLACE(Booth1_Temp,'F','') AS NUMERIC(4,1)) As Temp
FROM Paint_Environ
UPDATE:
You may start debug with this to see which data format give you error
SELECT Booth1_Temp
FROM Paint_Environ
WHERE ISNUMERIC(REPLACE(Booth1_Temp,'F','')) <> 1
I am trying to convert my Oracle query to SQL Server. The query shown below is causing some difficulty when trying to convert EXTRACTVALUE, XMLSEQUENCE, XMLTYPE functions.
Can anyone help me learn how to convert these to SQL Server?
EXTRACTVALUE(COLUMN_VALUE, 'pipeline/#name') NAME
FROM TABLE (SELECT XMLSEQUENCE(XMLTYPE(MESSAGE).EXTRACT('processEngine'))
FROM NMS_MESSAGES WHERE OBJECT_CODE='pe_monitor' AND ID=#WHERE:PARAM:USER_DEF:INTEGER:PARAM_PROCESS_ENGINE#)) INSTANCENAME
,(SELECT EXTRACTVALUE(COLUMN_VALUE, 'processEngine/#id') FROM TABLE (SELECT XMLSEQUENCE(XMLTYPE(MESSAGE).EXTRACT('processEngine'))
FROM NMS_MESSAGES WHERE OBJECT_CODE='pe_monitor' )) ENGINE_ID
Thanks in advance.
Think about XQuery. As I See that EXTRACTVALUE seems like #xml.values('(#node/#attr)[1]','type') and EXTRACT is #xml.nodes('path/path/path')
If know structure of xml that you ought to parse exactly than you will convert this query without any problems.
I am getting this error in my logs and I really do not know how to solve it.
"Conversion failed when converting the nvarchar value 'quiz.jpg' to data type int."
I am currently using ColdFusion 9. It seems that for whatever reason the site is trying to parse an image file into the database or something like that.
Any help will be appreciated.
Thanks
Are you using <cfqueryparam>?
I would guess that you may have something like this:
<cfquery param value="#myVar#" cfsqltype="cf_sqltype_integer" />
the cfsqltype should be cf_sqltype_varchar.
If that is not the case, then please update your post with the offending code. That would be very helpful.
I think we would need more of the error details like the line of code on which the error occurs or maybe the whole template to be much help. In the absence of more information, Jason's answer seems likely.
This sounds to me like you may have a query where you are trying to concatenate a nvarchar column with an int column.
Such as
SELECT MyString + MyInt FROM MyTable
Unfortunatly SQL Server does not implicitly convert integers to varchar for concatenation, so you will need to convert your integer.
SELECT MyString + Convert(varchar(20), MyInt) FROM MyTable
or
SELECT MyString + Cast(MyInt AS varchar(20)) FROM MyTable
I am pulling the following numbers from MS SQL Server:
345
345.6
345.67
How do I pull them so that they look like the following:
345.00
345.60
345.67
What datatype should they be stored as and what is the magic function to pull them?
Thank you.
You can use a cast function. Since you are pulling out values of a table, you would be using a select and some thing like the following can be used-
Select CAST(value AS DECIMAL(5,2)) from table
I hope that is what you are looking for.
cheers