How to extract date time from a column in KQL? - kql

I am trying to extract the Date time from a column ProtectionStatusDetails.
Below is the snip for this
snip

You can use the parse operator, e.g:
... | parse ProtectionStatusDetails with "AntivirusSignatureLastUpdated: " ts:datetime
Doc: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/parseoperator

Related

I have a Date in a String format and I can't convert it to date in BigQuery

I started with a date in a string format from a JSON extraction using this: json_value(answer, '$.date_created') and got an output 2020-01-02T10:26:47.056-04:00.
From there, I transformed the output (because I couldn't change it to date using a series of functions like regexp_replace, left and CAST) to a date-like string: 2020-01-02 10:26:47
I need to be able to transform this new string to a date. So far, I've tried with FORMAT_DATETIME and FORMAT_TIMESTAMP but I'm getting an error: Failed to parse input string bigquery
Your original timestamp string is just fine to do this:
select Date(timestamp("2020-01-02T10:26:47.056-04:00"))
Only thing here to check is: you have -4 offset from UTC so as long as you take care of timezone etc, above style should work fine.

Convert date column to character column

One of the columns is present in date datatype. I need to convert that date column in character datatype so that it can be concatenated with another character column.
Right now my date column is present in the following format : 09-JUN-2020.
Please help me in converting this column to character column.This needs to be done sas enterprise guide.
Thank u so much in advance.
You can use PUT() to convert from numeric to character. You need to find the format you want the output to look like and use that as your second parameter. Assuming you want your date to look like 2020-06-02 character this works:
*puts date as 2020-06-02;
newVar1 = put(dateVar, yymmddd10.);
*creates date variable as 02Jun2020;
newVar2 = put(dateVar, date9.);
FYI - You can find the list of formats available here

Extract date field from a sentence using SQL

I am trying to extract the date from a sentence like the below in SQL Server:
CC - Date of Pay - 7/26/2019;
Ideally, I would like to extract the date into its own column called DateofPay
Please try this code bellow :
SELECT SUBSTRING(RIGHT(`sentence`,10),1,9) as NewDate

Database table - Converting Date to Number

I am trying to convert a date to a number.
I need to have in my table a field with default value based on a date.
So if today is 23/01/2018, I want to have a number look like this 23012018.
Any ideas?
You can use the format command like this:
=Format$(Date, "ddmmyyyy")

Hive - UNIX_TIMESTAMP Quandary

Here is my 1 line of data (for brevity):
73831 12/26/2014 1:00:00 AM 0.3220
The 2nd column is the time column which is in string format. I'm using this hive query:
select col2, UNIX_TIMESTAMP(col2,'MM/DD/YYYY hh:mm:ss aaa') from Table
Here is what I get: 1388296800
However, when I check with, http://www.epochconverter.com/ and also from_unixtime(1388296800), I get a different date.
Is there something wrong with my format / pattern string I enter into UNIX_TIMESTAMP in Hive?
Your date format symbols need to conform to those in the Java SimpleDateFormat documentation.
For your date it looks like you want MM/dd/yyyy HH:mm:ss aa.