# API for Julian Dates

**URL:** <https://community.tulip.co/t/api-for-julian-dates/5750>\
**Category:** Support, Troubleshooting, & Help\
**Tags:** apps\
**Created:** [July 6, 2022, 8:36pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750 "2022-07-06T20:36:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![emendoza](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/emendoza/32/7446_2.png) [@emendoza](https://community.tulip.co/u/emendoza)\
**Post date:** [July 6, 2022, 8:36pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/1 "2022-07-06T20:36:02Z")

</div>

Does anybody are using an API or something to convert CURRENT DATE to Julian Format?  
As far as I know, Tulip does not has this feature, but I need this for a Manufacturing process.  
Hopefully somebody has a solution

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [July 6, 2022, 8:47pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/2 "2022-07-06T20:47:10Z")

</div>

@emendoza Admittedly, this is the first time I’ve heard of Julian format, but google tells me

> Julian day is the number of days since Monday, January 1, 4713 BC using the proleptic Julian calendar, which is November 24, 4714 BC, in the proleptic Gregorian calendar.

Postgres uses Julian days in its behind the scenes calculations and allows for a pretty simple method of calculation. Every Tulip instance comes with a “Connectors Demo” connector which I’ve often used for random calculations in the past.

You could make a connector function like the one shown below in order to quickly grab today’s Julian date

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/6/6659a638be29ea44a850d4c5b7e061ada906ea38.png)

---

<div class="post-metadata">

**Author:** ![emendoza](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/emendoza/32/7446_2.png) [@emendoza](https://community.tulip.co/u/emendoza)\
**Post date:** [July 6, 2022, 8:54pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/3 "2022-07-06T20:54:26Z")

</div>

This is great!!  
I just did it, but how can I get only the specific day number digits?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/3/3411e45e49948fbb7a962f596098be9e33ac7acf.png)

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [July 6, 2022, 9:21pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/4 "2022-07-06T21:21:36Z")

</div>

I may not fully understand this, but I think this may work.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/8/82703743385d9850c238c85e24d4e59cb7e597a1.png)

```auto
select (to_char(now()::date, 'J')::int - to_char(date_Trunc('year',now()), 'J')::int) as julian_date

```

At this point, though you may just be interested in the day number of the year, or the difference between today and Jan 1st

```auto
select now()::date - date_trunc('year',now())::date as julian_date

```

\*\*\*edit: you may want to add a +1 to the query, since I’m counting Jan 1 as “0” here

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [July 6, 2022, 9:27pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/5 "2022-07-06T21:27:43Z")

</div>

It’s probably worth noting that you can also do this with plain expressions if you just want the integer day from Jan 1st

---

<div class="post-metadata">

**Author:** ![emendoza](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/emendoza/32/7446_2.png) [@emendoza](https://community.tulip.co/u/emendoza)\
**Post date:** [July 6, 2022, 9:57pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/6 "2022-07-06T21:57:51Z")

</div>

Excellent!  
And think this solution will work.  
Will do some testing.

Really appreciate the answer!

Thanks

---

<div class="post-metadata">

**Author:** ![emendoza](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/emendoza/32/7446_2.png) [@emendoza](https://community.tulip.co/u/emendoza)\
**Post date:** [July 7, 2022, 12:28am UTC](https://community.tulip.co/t/api-for-julian-dates/5750/7 "2022-07-07T00:28:14Z")

</div>

@freedman I just did a test and it gives me Julian day as 187, and we still are in 186. I’m thinking this could be for the time zone. I’m in pacific time (San Diego). Is there a was in the query you send to me define time zone?

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [July 7, 2022, 12:44am UTC](https://community.tulip.co/t/api-for-julian-dates/5750/8 "2022-07-07T00:44:23Z")

</div>

@emendoza since you are only looking for the day number, it may be better to just use an expression. This would take into consideration your timezone (whereas the connector function will use whichever timezone the server is located in)

Here is an expression you can use

```auto
round(interval_to_seconds(rounddatetime(@App Info.Current Date and Time , 'day') - rounddatetime(@App Info.Current Date and Time , 'year')) / (60 * 60 * 24), 0)

```

![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/9/94b0af17e3686f5a896ae795f568f7cbb08a653b.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/7/7923f47f529a952d8ef822c3b5dcfa00a2940a3a.png)

---

<div class="post-metadata">

**Author:** ![emendoza](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/emendoza/32/7446_2.png) [@emendoza](https://community.tulip.co/u/emendoza)\
**Post date:** [July 7, 2022, 5:18pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/9 "2022-07-07T17:18:12Z")

</div>

Excellent!!!  
It seems it is working without any problem.

Thanks!

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [July 7, 2022, 5:25pm UTC](https://community.tulip.co/t/api-for-julian-dates/5750/10 "2022-07-07T17:25:39Z")

</div>

Closed on July 7, 2022, 5:25pm UTC


