# Retrieving date field in '%m/%d/%Y' format using the query

**URL:** <https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241>\
**Category:** Classic Servoy\
**Created:** [March 22, 2007, 12:56pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241 "2007-03-22T12:56:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rifluxyss](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rifluxyss](https://forum.servoy.com/u/rifluxyss)\
**Post date:** [March 22, 2007, 12:56pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/1 "2007-03-22T12:56:45Z")

</div>

Hi ,

Now i can able to display the date in a html format thats present inbetween two date field ,this can be done by getting the date field by a query(here i am gettting date field and other fields from four tables by four different query)and convert that into html by using the dataset.

Is it possible to do the same thats retrieve the date field in ‘%m/%d/%Y’ format means replace the current format 2006-11-06 00:00:00.0  
to ‘%m/%d/%Y’ by using mysql and display them in the html area in servoy.

Any thoughts ![:idea:]( "Idea") would be appreciated

---

<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:** [March 22, 2007, 1:24pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/2 "2007-03-22T13:24:26Z")

</div>

Hi,

I believe you are looking for the DATE\_FORMAT() function of MySQL.  
Since I don’t know what version of MySQL you run here are the pages for 4.1, 5.0 and 5.1. Although I don’t think much has changed between them.

[http://dev.mysql.com/doc/refman/4.1/en/ … tions.html](http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html)  
[http://dev.mysql.com/doc/refman/5.0/en/ … tions.html](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html)  
[http://dev.mysql.com/doc/refman/5.1/en/ … tions.html](http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![rifluxyss](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rifluxyss](https://forum.servoy.com/u/rifluxyss)\
**Post date:** [March 22, 2007, 2:05pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/3 "2007-03-22T14:05:11Z")

</div>

Exactly Robert ,

i tried by mean of the date\_format() in the query.But the dataset is not allowing that format.Is it not possible to use this function 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:** [March 22, 2007, 2:31pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/4 "2007-03-22T14:31:40Z")

</div>

That suprises me. I use database functions al over the place without any problems.  
Can you post the code here that gives you trouble ?

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [March 22, 2007, 2:57pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/5 "2007-03-22T14:57:12Z")

</div>

> ROCLASI:  
> Hi,
> 
> I believe you are looking for the DATE\_FORMAT() function of MySQL.  
> Since I don’t know what version of MySQL you run here are the pages for 4.1, 5.0 and 5.1. Although I don’t think much has changed between them.
> 
> [http://dev.mysql.com/doc/refman/4.1/en/ … tions.html](http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html)  
> [http://dev.mysql.com/doc/refman/5.0/en/ … tions.html](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html)  
> [http://dev.mysql.com/doc/refman/5.1/en/ … tions.html](http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html)
> 
> Hope this helps.

Wow Robert!!  
You’re acting like a walking manual lately… ![:D]( "Very Happy")

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [March 22, 2007, 3:04pm UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/6 "2007-03-22T15:04:54Z")

</div>

> rifluxyss:  
> Exactly Robert ,
> 
> i tried by mean of the date\_format() in the query.But the dataset is not allowing that format.Is it not possible to use this function in servoy.

I use the date\_format() functions all the time in my MySQL queries and it works perfectly, look at this:

```auto
select ddtid as "ID DDT",date_format(data_creazione, "%d-%m-%Y %H:%i") as "Data Creaz.",creatore as "Creatore",provenienza as "Provenienza",concat(procedura, " ", loadnumber) as "Load Num.",
ddt.status as "Status", date_format(date_add(data_creazione, interval procedure_sprint.scadenza_inventory day), "%d-%m-%Y %H:%i") as "Scad. Inventory" 
from ddt inner join procedure_sprint on ddt.procedura = procedure_sprint.nome_procedura
where ddt.status="Inventory"
order by date_add(data_creazione, interval procedure_sprint.scadenza_inventory day) asc;

```

What do you mean by saying “the dataset is not allowing that format”?  
If you fill a dataset with a sql query and then display it in a label everything is fine, if you want to use the dataset to populate a form you only need to retrieve the PKs of the records and not all the columns so you can adjust the date format using the format property of the field you use to show that column.  
Anyway don’t use a dataset to load a form, it is now (servoy 3.1.3) limited to 1000 records, use this instead:

```auto
controller.loadRecords(sql_query)

```

---

<div class="post-metadata">

**Author:** ![rifluxyss](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rifluxyss](https://forum.servoy.com/u/rifluxyss)\
**Post date:** [March 23, 2007, 9:22am UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/7 "2007-03-23T09:22:46Z")

</div>

Thanks for both robert and nick,

I had come to an end on this issue.I believe that i lead you all on the wrong direction that instead of sybase i mention as mysql.So that i ask sorry to both on this.

---

<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:** [March 23, 2007, 9:37am UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/8 "2007-03-23T09:37:06Z")

</div>

Hi,

It’s okay. We all get confused sometimes.  
So you found that you need to use [DATEFORMAT()](http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1000/en/html/dbrfen10/rf-dateformat.html) instead.  
Don’t you ‘love’ those slight differences between the main RDBMSs. ![:evil:]( "Evil or Very Mad")

---

<div class="post-metadata">

**Author:** ![rifluxyss](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rifluxyss](https://forum.servoy.com/u/rifluxyss)\
**Post date:** [March 24, 2007, 7:00am UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/9 "2007-03-24T07:00:34Z")

</div>

Yes Robert the difference between the RDBMS is really a ![:twisted:]( "Twisted Evil") ,

Instead of date format() in mysql we need to use the convert() function in sybase.These changes we need to make for the date conversion between both,I think these information will ensure other’s not to confuse in this matter.

---

<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:** [March 24, 2007, 10:59am UTC](https://forum.servoy.com/t/retrieving-date-field-in-m-d-y-format-using-the-query/7241/10 "2007-03-24T10:59:44Z")

</div>

I guess you can use CONVERT() for formatting dates but that is more a true casting function than a formatting function. If I read the reference pages correctly then you would normally use DATEFORMAT().  
Also that function is not much different than what other RDBMSs use other then the slightly different name.

[http://www.ianywhere.com/developer/prod … ormat.html](http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1000/en/html/dbrfen10/rf-dateformat.html)  
[http://www.ianywhere.com/developer/prod … nvert.html](http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1000/en/html/dbrfen10/rf-convert.html)

And the format styles used in DATEFORMAT():  
[http://www.ianywhere.com/developer/prod … ption.html](http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1000/en/html/dbdaen10/da-timestamp-format-option.html)

Hope this helps.
