Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Date conversion
tdavies
<p>Hi,</p><p> </p><p>My date fields in my report that are showing up like (eg.1371887407 ) what is the best way to convert big int to date time or just date?</p><p> </p><p>I tried adding a computed column using the expression</p><pre>df = new Packages.java.util.Date();df.setTime(row["field_1"]);df</pre><p>but it gives me the wrong date. It gives me Jan 16, 1970 4:04pm.</p><p> </p>
Find more posts tagged with
Comments
kclark
<p>Assuming that is POSIX Time you should be able to convert it like this.</p><pre class="_prettyXprint">var time = new Packages.java.util.Date();time = new Packages.java.util.Date( 1371887407*1000 );this.text = time;</pre><p>Place that in the onCreate() of a label and the output should be.</p><p> </p><div><pre class="_prettyXprint">Sat Jun 22 02:50:07 CDT 2013</pre></div>
tdavies
<p>Thanks for your reply.</p><p> </p><p>How can I set this up to convert all my date fields? I need to change the values in all the date fields not the labels. How can I set it up that as dates come they are converted?</p>
kclark
<p>I haven't tried it but I think you could create a computed column using an expression like this</p><pre class="_prettyXprint">var time = new Packages.java.util.Date();var posix = row["TIME"];time = new Packages.java.util.Date( posix*1000 );time;</pre><p>And then use your computed column in your report items.</p>
tdavies
<p>That worked except for fields that were null then it gave me 1969-12-31</p>