Loganathanpc
Loganathanpc

Reputation: 45

Azure Table Storage date time comparison with UTC and local time difference

I am trying to store and retrieve three datetime columns on azure table storage. Start date, End date and Last Executed date.

I have another fourth column which is called timeIntervalInMinutes. My code execution will happen on an azure VM which might be on any zone in US.

I am going to use these values to execute some task based on current time:

  1. start date >= current date <= end date
  2. Current time = Last Executed Date (time) + intervalInMinutes

There are few doubts that I have:

  1. The user is going to call this worker service on azure from their app, from any timezone US. Do I need to get their timezone in their request and store it along with the date time, which will get stored in UTC format on table storage?
  2. If Yes, then if the user tries to retrieve this configuration information, should I convert based on UTC to local time conversion?
  3. I need to execute my custom task based on the local time of the user. So when converting to UTC and storing it in the azure table, I need to say UTC + or - to suit the local time of the user's timezone?

Please help.

Upvotes: 0

Views: 1682

Answers (1)

The OP wrote in a comment:

I have solved this by adding entity properties with DateTimeOffset type and created separate fields for holding UtcOffset timespan value as ticks (long type). With this I can compare the UTC format timestamp with UtcOffset values and date as well for my scheduler to work. So it's now easy for me to query against date and as well as retrieve and present the user back with his / her own specified local time.

Upvotes: 1

Related Questions