Skip to main content
Sumo Logic

parseDate

The parseDate operator extracts a date or time from a string and provides a timestamp in milliseconds.

Syntax

  • parseDate(<strDate>, <dateFormat>)
  • parseDate(<strDate>, <dateFormat>, <timeZone>)

Rules

Example

Given a log message such as:

instance of Win32_NTLogEvent
{
	EventIdentifier = 100;
	Logfile = "Application";
	RecordNumber = 894528;
	SourceName = "Bonjour Service";
	TimeGenerated = "20170720000030.000000-000";
	TimeWritten = "20170720000030.000000-000";
	Type = "Error";
    ...

The following query returns TimeGenerated as a timestamp in milliseconds, in this example 1500534030000.

| parse "TimeGenerated = \"*.000000-000" as dd
| parseDate(dd, "yyyyMMddHHmmss") as milliseconds

To specify a time zone:

| parseDate(dd, "yyyyMMddHHmmss", "etc/utc") as milliseconds

See Also