Changing TimeStamp in Azure Sink for SLAB

Topics: Semantic Logging Application Block
Apr 1, 2014 at 8:47 PM
When I use AzureSinkSubscription to log my events in SLAB, how can I change the DateTime format in the Azure table?

Current DateTime Format: 4/1/2014 12:33:49 AM
Expected DateTime Format: 4/1/2014 22:32:12.9493551
Apr 3, 2014 at 2:34 AM
Edited Apr 3, 2014 at 2:35 AM
The EventDate is stored as a DateTime type in the Azure table. You can query the azure table and extract the value as DateTimeOffset and format however you wish.

Here's some sample code:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("SLABLogsTable");

TableQuery<DynamicTableEntity> projectionQuery = 
    new TableQuery<DynamicTableEntity>().Select(new string[] { "EventDate" });

EntityResolver<DateTimeOffset?> resolver = (pk, rk, ts, props, etag) => props.ContainsKey("EventDate") ? props["EventDate"].DateTimeOffsetValue: null;

foreach (var date in table.ExecuteQuery(projectionQuery, resolver, null, null))
{
    Console.WriteLine(date.Value.ToString("M/d/yyyy H:mm:ss.fffffff"));
}

When I run this I get the following: 3/19/2014 22:30:00.4170650 when in the Azure Table it is displayed as 3/19/2014 10:30:00 PM.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by BhavikHathi on 4/3/2014 at 5:21 PM
Apr 4, 2014 at 1:22 AM
It worked as expected. Thanks Randy !