logo
down
shadow

Need to calculate the sum of second using a function from a string variable using SQL


Need to calculate the sum of second using a function from a string variable using SQL

By : Zoey
Date : October 18 2020, 06:10 PM
I wish did fix the issue. There is a column named as duration in a table called Adventurous.The column has values as below.In the column Suffix of 'H' is hours,Suffix of 'M' is minutes and Suffix of 'S' is seconds.How can we select the hours, minutes and seconds and convert all into seconds i.e sum of all the hours minutes and seconds in the form of seconds. , Try this:
code :
Declare @t table (duration varchar(50))

insert into @t values  ('PT1H2M18S')

select   
        convert(int,substring(duration,CHARINDEX('PT',duration)+2,(CHARINDEX('H',duration)-CHARINDEX('PT',duration))-2))*3600 +
        convert(int,substring(duration,CHARINDEX('H',duration)+1,(CHARINDEX('M',duration)-CHARINDEX('H',duration))-1))*60 +
        convert(int,substring(duration,CHARINDEX('M',duration)+1,(CHARINDEX('S',duration)-CHARINDEX('M',duration))-1))
        from @t


Share : facebook icon twitter icon
How to calculate the derivate of a function for a set variable?

How to calculate the derivate of a function for a set variable?


By : user83213
Date : March 29 2020, 07:55 AM
it should still fix some issue Let's say I input following sentences: , You need to use symbolic expression:
code :
syms x y            % creates symbolic variables x,y
y = x^2;            % symbolic expression
t = diff(y);        % t = 2*x (differentiate symbolic expression of y)
z = subs(t, x, 5)   % evaluate t, i.e. z=2*5=10
When we pass string variable as ref argument to function and change value of string variable in function

When we pass string variable as ref argument to function and change value of string variable in function


By : user2981034
Date : March 29 2020, 07:55 AM
I hope this helps . You are asking about 2 separate things:
1. Strings and String Data
code :
static void Main()
{
   String str1 = "sample";
   String str2 = str1;
   ChangeString(ref str1);
}
void ChangeString(ref string str)
{ 
   str = "New Sample";
}
static void Main()
{
   String str1 = "sample";
   String str2 = str1;
   str1 = "New Sample";
}
Calculate variable String(010) with integer(1) where outcome is string(011)

Calculate variable String(010) with integer(1) where outcome is string(011)


By : Unacorn
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Considering you are handling Integer number (not binary )
Try something like this:
code :
String input ="001";//your user input
    /**
     * your check here if input is a  number
     */
    int len=input.length();
    int inputInteger=Integer.parseInt(input);
    inputInteger+=1;

    String output=String.format("%0"+len+"d", inputInteger); 
    System.out.println(output);
What's the way to just calculate a variable when it's called in a function?

What's the way to just calculate a variable when it's called in a function?


By : Robert MacDonald
Date : March 29 2020, 07:55 AM
Hope that helps
i want to know if are there a way to check the elements used by fn(), and just calculate those.
SPSS - calculate new variable from two string using if-then

SPSS - calculate new variable from two string using if-then


By : Udenwa Chidi
Date : March 29 2020, 07:55 AM
This might help you I need to develop a statement that will pull string values from two col based on their values and missing values. For example. , This should do it:
code :
string new_var(a20).
if (COL_A<>"" and COL_B<>"") or COL_B="" new_var=COL_A.
if new_var="" and COL_B<>"" new_var=COL_B.
Related Posts Related Posts :
  • Programmatically creating linked tables in access
  • Is there meta data I can read from SQL Server to know the last changed row/table?
  • Combine two Column into One column with out union
  • Switch CASE in stored procedure in SQL
  • VS 2019 SSIS package can't add SQL Server
  • Partition or Index large table in SQL Server
  • How to remove only certain items within a column that has multiple words listed in cell
  • How to convert from DD/mm/yyyy in varchar(max) to yyyymmdd format in SQL Server
  • Error copying SQL Server database from one server to another
  • SQL Server: link DB2 table
  • Inner Join Query with 2 tables giving different result compared to Sub Query for same 2 tables Northwind database
  • After a specific time of day - which method is better?
  • Select cities from table, which do not start with vowels and do not end with vowels
  • Call stored procedure for each row from select
  • To split records in one column into multiple columns
  • Why does LEN( char(32) ) = 0 in T-SQL?
  • Select all date between which an object has certain properties
  • Difference between SSDT in VS and Integration Services in SQL Server
  • Creating a function for a snap, crackle, pop
  • date function will return different date if date changes while executing the query?
  • SQL: Can this be written more efficiently?
  • Why are and are the same in SQL Server
  • How to call a SQL Server procedure with both input and output parameters?
  • How can I restore an SQL Server database when starting the Docker container?
  • What is different between the two methods of generating cluster primary keys?
  • How to handle a subquery with no results?
  • Access linked to SQL Server shows #Name? in fields after filtering
  • I am getting this error even after declaring scalar variable"'Must declare the scalar variable "@col_shipping_
  • What is the difference between 'CREATE USER [user_name] FOR LOGIN [login_name]' and 'CREATE USER [user_name] FROM LOGIN
  • How to fix error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near ','.?
  • How to migrate collections from TFS 2017 to Azure DevOps Server 2019 (Different DB servers)
  • How to select from table one with all records from table 2
  • SQL Server INSERT INTO using transaction
  • A simple pivot but can't get my head around it - please assist..:-)
  • Why would adding a simple field to select change the amount of returned rows SQL
  • Read file in SSIS Project into a variable
  • Cleaning dupes and keeping max data
  • How to select date and previous date
  • How to delete from multiple tables in one DELETE statement in a .cfc file?
  • Is it possible to get "NT AUTHORITY\NETWORK SERVICE" user independent of language?
  • SQL Server select query very slow
  • Go MSSQL Connection
  • What are good practices for granting database permissions to a web service connection?
  • ARX Anonymization Tool - supported databases
  • How to extract every 7 characters of an nvarchar into another table?
  • MD5 Hashing in SQL Server
  • SQL Server : column data extraction
  • The nullability property of arithmetic operators over floating point data type in SQL Server
  • SQL Server Wildcard Length
  • How to import .bak file into SQL Server?
  • Convert HH:MM TT to Time and append onto date
  • Dynamic stored procedure to update a table
  • How do you debug or step through the code in SQL Server Management Studio 18?
  • How to combine rows of similar results into one?
  • How to copy databases automatically from one server to another in efficient way (not backup and restore)
  • How to convert Row by row execution in to SET based approach in SQL
  • How to use INSERT INTO OPENROWSET to export to Excel without being an admin on the target server
  • SQL SERVER job is not executing SSIS
  • Rounding up starting 6
  • Why my main query is running successfully at the same time as subquery returns an error?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk