# Date function problem

**URL:** <https://forum.servoy.com/t/date-function-problem/14067>\
**Category:** Classic Servoy\
**Created:** [May 30, 2011, 4:01pm UTC](https://forum.servoy.com/t/date-function-problem/14067 "2011-05-30T16:01:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michele](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@michele](https://forum.servoy.com/u/michele)\
**Post date:** [May 30, 2011, 4:01pm UTC](https://forum.servoy.com/t/date-function-problem/14067/1 "2011-05-30T16:01:48Z")

</div>

Hi, i have a date variable  
dDataIn = Tue Jul 05 00:00:00 CEST 2011  
i need to get from this date the last day of the month (ie 30-06-2011)  
i have used Date() function in this way  
var dNewData = Date(dDataIn.getFullYear(),dDataIn.getMonth(),30)  
but the new variable has this value  
Mon May 30 2011 17:40:21 GMT+0200 (CEST)

Why ?  
In the Debug  
i have dDataIn.getFullYear() → 2011.0  
dDataIn.getMonth() → 6

Why not 30-6-2011 ?

Thanks

---

<div class="post-metadata">

**Author:** ![michele](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@michele](https://forum.servoy.com/u/michele)\
**Post date:** [May 30, 2011, 4:17pm UTC](https://forum.servoy.com/t/date-function-problem/14067/2 "2011-05-30T16:17:52Z")

</div>

I missed the new clause…  
var dNewData = new Date(dDataIn.getFullYear(),dDataIn.getMonth(),30)

Another question…  
I have my date variable and i wan to sum a number of days to that date…  
In Visual Foxpro (the language i have evere used) i used  
dVar = dVar + 60

In servoy ?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [May 30, 2011, 10:27pm UTC](https://forum.servoy.com/t/date-function-problem/14067/3 "2011-05-30T22:27:41Z")

</div>

Hi michele,

> michele:  
> I have my date variable and i wan to sum a number of days to that date…  
> In Visual Foxpro (the language i have evere used) i used  
> dVar = dVar + 60
> 
> In servoy ?

In JavaScript (and therefor Servoy) you can do it the following way:

```auto
dVar = new Date(dVar.getFullYear(), dVar.getMonth(), dVar.getDate() + 60); // add 60 days

```

Of course you could also use the [mod\_datejs](https://www.servoyforge.net/projects/mod-datejs) module from Greg Pierce, which is based on the open source library [datejs](http://www.datejs.com/).  
Then you can use the following syntax:

```auto
dVar.addDays(60);

```

Hope this helps.
