Select to view content in your preferred language

date output format

1128
6
07-01-2010 02:05 AM
AlessioDi_Lorenzo
Emerging Contributor
Hi all,

when I execute a query against a mapservice i get dates in this format:

Mon Jun 28 00:00:00 CEST 2010

using jquery I'm able to format it as dd/mm/yyyy

My question is:
is there a way to translate the date directly into the query?
Something like:

// Query
myQuery = new esri.arcgis.gmaps.Query();
myQuery.outFields = ["ID","NAME","TO_CHAR(DATE, dd/mm/yyyy)"];
myQuery.where = "1=1";


thx
0 Kudos
6 Replies
AdamPfister
Esri Contributor
what you've shown there is not possible i don't think.  if you want it coming in directly as a formatted date i think your only option is to create a new field and calculate it from the DateTime field as text in whatever format you need.   then you can specify that new field in your outFields list.
0 Kudos
AlessioDi_Lorenzo
Emerging Contributor
what you've shown there is not possible i don't think.  if you want it coming in directly as a formatted date i think your only option is to create a new field and calculate it from the DateTime field as text in whatever format you need.   then you can specify that new field in your outFields list.


mmm... yes, it works but it is still a workaround (even if better than the javascript one...) and I was looking for a native solution 🙂

Thanks anyway

OT
In my opinion esri's js apis is a good tool but it has to be improved from the point of view of the query management. At least ORDER BY and GROUP BY clause and the DISTINCT selection have to be supported!
0 Kudos
AdamPfister
Esri Contributor
mmm... yes, it works but it is still a workaround (even if better than the javascript one...


awesome.  i had no idea you could inject SQL in that way.
0 Kudos
derekswingley1
Deactivated User
You can, but it's kind of hacky and dependent on what is supported by the underlying data source. I would still format the date with JavaScript.
0 Kudos
hayaticm
Emerging Contributor
have you found the solution?
mine is coded this way:

layerDefs[0] = "ZON='DATE = TO_DATE('"+ (dojo.byId('DATE').value) +"','YYYY-MM-DD')";
0 Kudos
AlessioDi_Lorenzo
Emerging Contributor
have you found the solution?
mine is coded this way:

layerDefs[0] = "ZON='DATE = TO_DATE('"+ (dojo.byId('DATE').value) +"','YYYY-MM-DD')";


thank you, but using the google extensions apis I prefer jquery to dojo.
Formatting date with javascript is quite simple in jquery also:

$.format.date(attribute["FIELD_NAME"],'dd/MM/yyyy')


So, I was looking for something different from a javascript workaround but at the moment - if I understood well - it is not possible.
0 Kudos