# date function

**URL:** <https://forum.servoy.com/t/date-function/694>\
**Category:** Classic Servoy\
**Created:** [November 18, 2003, 3:10pm UTC](https://forum.servoy.com/t/date-function/694 "2003-11-18T15:10:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 18, 2003, 3:10pm UTC](https://forum.servoy.com/t/date-function/694/1 "2003-11-18T15:10:53Z")

</div>

we use in Filemaker:

> Date(Month;1;Year) - DayofWeek(Date(Month;1;Year)) + 1

BTW: Month and Year are in Filemaker, number fields.

Does anyone know how to convert this in Servoy?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 18, 2003, 3:25pm UTC](https://forum.servoy.com/t/date-function/694/2 "2003-11-18T15:25:54Z")

</div>

> Date(Month;1;Year) - DayofWeek(Date(Month;1;Year)) + 1

I would say (where d as type date):

var dd = new Date(d.getYear, d.getMonth, d.getDate - d.getDay + 1)

where getDate = day of Month and getDay = day of Week (0 = sunday)…

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 18, 2003, 9:39pm UTC](https://forum.servoy.com/t/date-function/694/3 "2003-11-18T21:39:59Z")

</div>

Not completly, but I could (with help from your example) make the right one

```auto
var a = new Date(year1, month1, 1)
var b = a.getDay + 1
datecalc = a.setDate(a.getDate()- b)

```

Thanks.
