Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

Entityimage_timestamp field on contact entity

Posted on by 30

Hi,

I need to import entityimage field from contact entity which is customer profile picture. 

Code written and pictures coming through. 

But, I need to when the customer uploads new file.

I can see a field in contact entity entityimages_timestamp field. It is int64

What is this field actually?

How can I convert to proper timestamp 

  • rajkm Profile Picture
    rajkm 65 on at
    RE: Entityimage_timestamp field on contact entity

    Thanks. It is working

  • Verified answer
    Eiken Profile Picture
    Eiken on at
    RE: Entityimage_timestamp field on contact entity

    Hi,

    I think that this timestamp number is DateTime.Ticks.

    DateTime.Ticks Property (System) | Microsoft Learn

    Please try the following code.

    DateTime dt = DateTime.MinValue.AddTicks(634876488000000000);

    or
    DateTime dt = new DateTime(634876488000000000);
  • rajkm Profile Picture
    rajkm 65 on at
    RE: Entityimage_timestamp field on contact entity

    Do I need to deduct 1600(year) to get actual year?

    long timestamp = (long)contact["entityimages_timestamp"];

    DateTime dateTime = new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddTicks(timestamp);

    Convert the DateTime object to a string representation:

    string timestampString = dateTime.AddYears(-1600).ToString("yyyy-MM-dd HH:mm:ss");

  • Suggested answer
    Eiken Profile Picture
    Eiken on at
    RE: Entityimage_timestamp field on contact entity

    DATEADD(datepart,number,date) function is available in SQL Server.

    Please refer to the following link.

    How can I convert bigint (UNIX timestamp) to datetime in SQL Server? - Stack Overflow

     By the way, the data is obtained with hours, minutes and seconds, then you can use another CONVERT () function to remove the hours, minutes and seconds.

    Example:

    CONVERT(varchar(100),(SELECT DATEADD(s, dataeField / 1000, '1970-01-01 08:00:00')),23)

  • rajkm Profile Picture
    rajkm 65 on at
    RE: Entityimage_timestamp field on contact entity

    I have tried your suggestion. I got the data but the year shown as 3622 it is strange

       DateTime dt = new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddTicks(637874475651022629);

       MessageBox.Show(dt.ToString("yyyy-MM-dd HH:mm:ss"));

    entityimage_timestamp: 637874475651022629

    o/p: 3622-05-16 15:26:05

  • rajkm Profile Picture
    rajkm 65 on at
    RE: Entityimage_timestamp field on contact entity

    Sorry, I am in Sql server end.

  • Suggested answer
    Eiken Profile Picture
    Eiken on at
    RE: Entityimage_timestamp field on contact entity

    Hi,

    You can convert the timestamp to date with the following function(from_unixtime) in MySql

    MySQL FROM_UNIXTIME() function - w3resource

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,215 Moderator on at
    RE: Entityimage_timestamp field on contact entity

    hi

    the entityimage field in the Contact entity stores the customer's profile picture. The entityimages_timestamp field is a system field that stores the timestamp of the last time the entityimage field was updated.

    The entityimages_timestamp field is stored as a 64-bit integer value that represents the number of 100-nanosecond intervals since January 1, 1601 (Coordinated Universal Time). To convert this value to a proper timestamp, you can use the following formula:

    Convert the entityimages_timestamp value to a DateTime object:

    long timestamp = (long)contact["entityimages_timestamp"];

    DateTime dateTime = new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc)

                       .AddTicks(timestamp);

    Convert the DateTime object to a string representation:

    string timestampString = dateTime.ToString("yyyy-MM-dd HH:mm:ss");

    This will give you a string representation of the timestamp in the format "yyyy-MM-dd HH:mm:ss". You can then use this string to display or compare the timestamp as needed.

    DAniele

  • rajkm Profile Picture
    rajkm 65 on at
    RE: Entityimage_timestamp field on contact entity

    Hi Eiken

    Thanks for the reply.

    But it is a BIGINT, how do I know equivalent actual date and timestamp value. Either in C# code or sql end

  • Suggested answer
    Eiken Profile Picture
    Eiken on at
    RE: Entityimage_timestamp field on contact entity

    Hi,

    I find the definition of "EntityImage_Timestamp" in a past document.

    Image Properties | Microsoft Learn

    pastedimage1678085551205v1.png

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,137 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans