Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.
SOLVED

Date Conversion in calculated field from unix time to normal date

Avatar

Level 2

Hi All, I'm facing issue while converting unix timestamp to date field. here im using dformat for conversion and im getting only null values, but if i use specific timestamp like this -1652246442000 instead of "AnnivesaryDate" its showing me the correct result

the condition:

Abishek_mathav12345678_0-1718204189094.png

results

Abishek_mathav12345678_1-1718204216132.png

end result should be in this format 2022-02-10 so,can anyone help with these issue?

sample data which i used:

Abishek_mathav12345678_2-1718207072281.png

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2

yeah correct while ingestion its taking the field(annivesaryDate) as string 

Abishek_mathav12345678_0-1718601650529.png

 

 

That’s the reason while performing dformat function in calculated field its showing null value and i have corrected the value(data in csv to 9digits(seconds) from 13digits(milliseconds) format) and while performing dformat function I have multiplied 1000 to field(annivesaryDate) so it will be in milliseconds format(dformat only accepts milliseconds) and now i can see the data in date format.

Abishek_mathav12345678_1-1718602157679.png

 

 Thank you all for your inputs

View solution in original post

6 Replies

Avatar

Community Advisor

hi @Abishek_mathav12345678 

You are getting this error because you are trying this with a string(aniversaryData), but it is a field.

Try wrapping the field name in ${} to make it a legal identifier.

example: dformat(${aniversaryData},"yyyy-mm-dd")

Thanks for the reply @Ankit_Chaudhary 

I tried with your input also still showing null values, any other pointer on this will be helpful.

 

Avatar

Community Advisor

Hi @Abishek_mathav12345678 

Looks like timestamp values in you aniversaryDate filed is in seconds format, currently dformat function support timestamp in milliseconds(I guess). You need to convert your data into milliseconds by adding 3 extra 0 at the end and make it a 13 digit timestamp number.

Ankit_Chaudhary_1-1718259675903.png

 

Ankit_Chaudhary_0-1718259651670.png

 

yes its already in milliseconds and i was performing batch ingestion

my data is 

Abishek_mathav12345678_0-1718261133364.png

if i explicitly mention the timestamp its showing the result correctly in calculated field

Abishek_mathav12345678_2-1718261524194.png

 

but if i use the field(annivesaryDate)its showing null

Would like to understand, if you just reference the field(annivesaryDate), without dformat function, what is it returning at the moment?

Because, if it is stored as string, the additional characters, might be causing an issue. If that is the case you observe, you should have an additional to_int()/to_bigint() to convert the string to numeric value, since the dformat accepts bigint as the parameter. 
Hope this helps!

Avatar

Correct answer by
Level 2

yeah correct while ingestion its taking the field(annivesaryDate) as string 

Abishek_mathav12345678_0-1718601650529.png

 

 

That’s the reason while performing dformat function in calculated field its showing null value and i have corrected the value(data in csv to 9digits(seconds) from 13digits(milliseconds) format) and while performing dformat function I have multiplied 1000 to field(annivesaryDate) so it will be in milliseconds format(dformat only accepts milliseconds) and now i can see the data in date format.

Abishek_mathav12345678_1-1718602157679.png

 

 Thank you all for your inputs