Converting DATE or DATETIME to INT (format YYYYMMDD) declare @dt datetime set @dt = '\09-22-2007 15:07:38.850\' select cast(convert(char(8),@dt,112) as int) Converting INT (format YYYYMMDD) to DATE declare @dti int = 20071022; select cast(@dti as datetime)
Example of date trimming to minutes and hours: declare @dt datetime set @dt = '09-22-2007 15:07:38.850' select dateadd(mi, datediff(mi, 0, @dt), 0) select dateadd(hour, datediff(hour, 0, @dt), 0)
A simple example of finding trailing zeros in the factorial of N. public int TrailingZeroes(int n) { int result = 0; while(n!=0){ result += n/5; n = n/5; } return result; }
Given: An array of points on a plane: points[][] Xi and Yi. Need to find: The maximum number of points that belong to one line. Example: Original array: points= [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] Result: 4 Example solution, not the best, but working: Explanation of the algorithm: Create a dictionary where the key is a pair [line equation + index of coordinates in the array].
How to add data to a table with a Primary Key (when you need to ignore this primary key) SET IDENTITY_INSERT tableA ON -- Now you can make a list of fields with Primary Key and add records like: INSERT Into tableA ([id], [c2], [c3], [c4], [c…
Example of rounding date to hour and minute declare @dt datetime set @dt = '09-22-2007 15:07:38.850' select dateadd(mi, datediff(mi, 0, @dt), 0) select dateadd(hour, datediff(hour, 0, @dt), 0)
Example of rotating/shifting an array Array K times in C# Meaning on example: There is an array: [1,2,3,4,5] We rotate it 3 times: K=3. Result: [3,4,5,1,2]
In the previous part (Python Bottle Guide (Translation) Part 5 - Request Data (data in the request)) we considered the main aspects related to the data transmitted in requests, in this part we will briefly consider the use of templates.
In the previous part (Python Bottle Guide (Translation) Part 4 - Creating Content) we considered the main aspects related to the transmitted content, in this part we will consider the data transmitted in requests. Files Cookie, HTTP headers, HTML form fields, and other request data are available through the global request object. This special object always refers to the current request, even in multi-threaded environments where multiple client connections are being processed simultaneously:
In the previous part (Python Bottle Guide (Translation) Part 3 - Routing Requests), we discussed the main aspects related to routing requests. In this part, we will discuss the aspects related to the transmitted content. S...