# dates in prepared statements

**URL:** <https://forum.servoy.com/t/dates-in-prepared-statements/6012>\
**Category:** Classic Servoy\
**Created:** [May 31, 2006, 9:48am UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012 "2006-05-31T09:48:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [May 31, 2006, 9:48am UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/1 "2006-05-31T09:48:59Z")

</div>

Hello,

I just came across this problem: I am using this code to find some data

```auto
var vNow = new Date();
var vQuery = 'SELECT ... WHERE date <= ' + ?;
var vArgs = new Array();
vArgs[0] = vNow;
var vDataset = databaseManager.getDataSetByQuery(..., vArgs, -1);

```

Servoy uses this

```auto
questiondata[1]= 2006-05-31 ,type: java.sql.Date

```

as the date criteria. The problem is, that here I also need the time portion of the date. How can I manipulate the way the date is passed as argument?

Any help appreciated.

Thanks  
Patrick

---

<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:** [May 31, 2006, 1:17pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/2 "2006-05-31T13:17:45Z")

</div>

Shouldn’t the time portion be considered also?

What is your dateprovider type? Really a datetime or timestamp or so?

Otherwise you can always search on a string format like data = ‘yyyy-MM-dd 00:00’ but… That is database dependent so when you can avoid it I would do so!

Ciao

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [May 31, 2006, 1:26pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/3 "2006-05-31T13:26:36Z")

</div>

> That is database dependent so when you can avoid it I would do so!

That is exactly the reason why I chose to use a prepared statement. The field stores a datetime (I also see the time portion in any form). With the code given above, Servoy ignores the time portion. That’s my problem.

---

<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:** [May 31, 2006, 1:29pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/4 "2006-05-31T13:29:10Z")

</div>

I understand and it is strange… Which Servoy version?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [May 31, 2006, 1:43pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/5 "2006-05-31T13:43:37Z")

</div>

2.2.5

---

<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:** [May 31, 2006, 2:11pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/6 "2006-05-31T14:11:38Z")

</div>

Hmm, I would file it as an issue.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [May 31, 2006, 2:18pm UTC](https://forum.servoy.com/t/dates-in-prepared-statements/6012/7 "2006-05-31T14:18:16Z")

</div>

I did.
