![]() ![]() Don't worry about 1000, it only assures that we will have the rest of the string, not any less. If the day of week part may have variable length. Or even better substring(myDatetimeString, charindex(' ', myDatetimeString), 1000) So all you need to do is cut out the Fri part: substring(myDatetimestring, 5, 1000) Oracle: - Specify a datetime string literal. Run the T-SQL script below to create the two tables. This should be on a SQL Server that also has SQL Agent since we will use a scheduled job to centrally collect the data. (And, of course, I agree with the comments that dates should be stored in DATE data types in the database. CAST AS DATE CAST(expression AS DATE formatclause) Description. Step 1 - Create Tables to Store Data Create two tables on any SQL Server instance where you want to run and collect the data for your servers and databases. An undelimited string of integers is assumed to be Year-Month-Day order. Note that the TODATE and STRTODATE format strings are different. 3 Answers Sorted by: 5 I understand your problem to be how to successfully convert the string into a DATE value. It's your format except it doesn't include unnecessary in this case day of week information. In MariaDB, you can use STRTODATE function. If you are converting two-digit years with TODATE, use either the RR or YY format string. The target column must be date/time for TODATE expressions. You use the TODATE format strings to specify the format of the source strings. There you can find, that the closest date format is indicated by 100: 0 100 mon dd yyyy hh:miAM/PM Default Converts a character string to a date datatype in the same format as the character string. ![]() When dealing with non-standard date formats, I usually lookup CONVERT function in SQL Server, as it io very "elastic": you can provide various formats to it, so it recognizes them appropriately. ![]()
0 Comments
Leave a Reply. |