# Access current datetime in Table analytic?

**URL:** <https://community.tulip.co/t/access-current-datetime-in-table-analytic/7078>\
**Category:** General\
**Tags:** analytics\
**Created:** [December 12, 2022, 8:14pm UTC](https://community.tulip.co/t/access-current-datetime-in-table-analytic/7078 "2022-12-12T20:14:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard-SNN](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/richard-snn/32/1166_2.png) [@Richard-SNN](https://community.tulip.co/u/Richard-SNN)\
**Post date:** [December 12, 2022, 8:14pm UTC](https://community.tulip.co/t/access-current-datetime-in-table-analytic/7078/1 "2022-12-12T20:14:09Z")

</div>

Is there a way to access the current datetime stamp in a table analytic?

I’m trying to create an aging analytic and I know when the record was created but I have no way (that I can tell) to calculate the duration delta between now and then.

---

<div class="post-metadata">

**Author:** ![Richard-SNN](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/richard-snn/32/1166_2.png) [@Richard-SNN](https://community.tulip.co/u/Richard-SNN)\
**Post date:** [December 15, 2022, 3:05pm UTC](https://community.tulip.co/t/access-current-datetime-in-table-analytic/7078/2 "2022-12-15T15:05:40Z")

</div>

To close the loop on this, the answer is no.

It took me the better part of yesterday but I figured out how to use the Tulip Node Red API nodes and perform the calculation outside of the platform.

Here’s the flow I ended up with:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/0/0428cbab607248ce3a737b7f0009370cc00af119.png)

If there is interest I can try to document it in detail but here’s the key points:

If your query will return more than 100 records, you need to use flow variables to keep track of where you are.

1. Setting the initial values:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/3/38a5cfa8dc9fa7c3d59595ae90e1e1493d83c320.png)

2. Write them to the flow variables. NOTE: The `includeTotalCount` is a more expensive query on the server but it’s required so you can track how many times to loop over the records.  

3. The `split` node is needed because we need to update the records one at a time.

4. Because I decided to use an `Interval` Tulip data type I need the result in seconds. Since Node Red uses microseconds the results need to be divided by 1000.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/7/75817c82521fbba2a074f19935ed5bda48bd3fce.png)

5. The record count returns as a string so convert it to a number:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/5/5a72f67730dae9065b69a56015117126811a7cd6.png)

6. I ended up using a negative condition to know when to stop looping. Basically when the number of records remaining is less than the query limit, stop.  
NOTE: The record count is relative to the offset so it will actually decrease by 100 every time you loop.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/a/a9b5a7df6a6ef0e8bddeae2638da76a4ea63c920.png)

7. Only continue looping if the response is `200` which means everything is good.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/1/1b1d85f3d82697ab31be59ee8f7898effbb5c6b0.png)

8. Calculate the offset increment and save back to the offset flow variable.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/6/6bf3e9e54f444321690f5592f5ea7c231dd363b8.png)

9. Use the flow variables to set the message inputs for the next query:  

10. Make sure to change the `Output as` from `plain text` to `Parsed JSON` or it will not be accepted by the Tulip Record Update node.

I could keep going but hopefully this is enough to save you half a days work!

---

<div class="post-metadata">

**Author:** ![stefan](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@stefan](https://community.tulip.co/u/stefan)\
**Post date:** [September 13, 2024, 12:43pm UTC](https://community.tulip.co/t/access-current-datetime-in-table-analytic/7078/3 "2024-09-13T12:43:11Z")

</div>

Hey @Richard-SNN, a late follow up to this: Release r288 will include a `CURRENTDATEANDTIME()` function in the analytics expression editor.

[Here](https://tulip.widencollective.com/assets/share/asset/mukylzsiww) is a quick demo with a few examples for how to use it.
