Page 106 - Computer Software Application TP - Volume 1
P. 106

COMPUTER SOFTWARE APPLICATION - CITS




           3  DATEDIFF() – Calculate the difference between two dates
           SELECT DATEDIFF(‘2022-01-01’, ‘2021-12-15’);
           -- Result: 17 (days)




















           TASK 3 :Using CHARACTER Functions:
           1  CONCATE() – Concatenate strings
           SELECT CONCAT(‘Hello’, ‘ ‘, ‘World’);
           -- Result: Hello World



















           2  LENGTH() – Length of a string
           SELECT LENGTH(‘abcde’);
           -- Result: 5

           3   SUBSTRING() – Extract part of a string
           SELECT SUBSTRING(‘abcdef’, 2, 3);
           -- Result: bcd
           1  How do you calculate the difference in days between two date columns?
           SELECT DATEDIFF(end date, start date) FROM your table;

           2  How can you concatenate two columns and add a separator between them?
           SELECT CONCAT(column1, ‘ - ‘, column2) AS concatenated columns FROM your table;
           3  How can you find the length of string column?
           SELECT LENGTH(string column) FROM your table;










                                                           91
 CITS : IT & ITES - Computer Software Application - Exercise 28   CITS : IT & ITES - Computer Software Application - Exercise 28
   101   102   103   104   105   106   107   108   109   110   111