When editing date attribute gets saved one day into the past

610
3
10-31-2011 04:23 AM
MarkSmith
New Contributor III
Hello,

I have a problem with V2.5 of the JS API (although seems to be the same for previous versions).  The problem is editing and entering a date attribute which then gets saved to the database with a date one day into the past.  I have seen some similar forum posts about this, but not relating to the JS API, and not specifically like my problem ??? I will attempt to describe below.

Layers come from SDE V10, SP1 and some have date fields.  Using the out the box template picker and editor dijits (so no custom code) a user can place a point on the map and the attribute info window pops up and they can pick a date from the date picker.  If they pick today's date, or a date into the future then that date gets saved correctly into the database.  HOWEVER, if they pick a date in the past, then the date gets saved to the database one day further into the past.  For example a user selects 31/10/2011 in the date picker (and the current date is the same 31/10/2011) then this saves as you would expect as 31/10/2011 into the database, if they select 30/10/2011 (yesterday), this gets saved as 29/10/2011 in the database.  What's also interesting is that the value in the database is 29/10/2011, but when the user edits the point attributes using the info window, the displayed date is 30/10/2011.

This must have something to do with the info window attribute editor code, but as this is out of my control I don't know how to fix this problem.  It is very strange that only past dates exhibit this problem.  This is an issue because I want to store correct dates in the database of course.  I'm in the UK by the way which might have a bearing.

Can anyone please help solve this puzzle?

Thank you, Mark.
0 Kudos
3 Replies
HemingZhu
Occasional Contributor III
Hello,

I have a problem with V2.5 of the JS API (although seems to be the same for previous versions).  The problem is editing and entering a date attribute which then gets saved to the database with a date one day into the past.  I have seen some similar forum posts about this, but not relating to the JS API, and not specifically like my problem �?? I will attempt to describe below.

Layers come from SDE V10, SP1 and some have date fields.  Using the out the box template picker and editor dijits (so no custom code) a user can place a point on the map and the attribute info window pops up and they can pick a date from the date picker.  If they pick today's date, or a date into the future then that date gets saved correctly into the database.  HOWEVER, if they pick a date in the past, then the date gets saved to the database one day further into the past.  For example a user selects 31/10/2011 in the date picker (and the current date is the same 31/10/2011) then this saves as you would expect as 31/10/2011 into the database, if they select 30/10/2011 (yesterday), this gets saved as 29/10/2011 in the database.  What's also interesting is that the value in the database is 29/10/2011, but when the user edits the point attributes using the info window, the displayed date is 30/10/2011.

This must have something to do with the info window attribute editor code, but as this is out of my control I don't know how to fix this problem.  It is very strange that only past dates exhibit this problem.  This is an issue because I want to store correct dates in the database of course.  I'm in the UK by the way which might have a bearing.

Can anyone please help solve this puzzle?

Thank you, Mark.


Enable time on the layer in you .mxd/.msd. Setting up the time zone to your time zone.
0 Kudos
MarkSmith
New Contributor III
Thanks, but this didn't make any difference.
0 Kudos
DavidHollema
New Contributor III
I just tested this very thing and don't see the behavior you're referring to.  I'm using jsapi v2.6.  Could it be an issue with the fact that the feature service writes UTC times into SDE and you're displaying local times?  However that shouldn't change the date.
0 Kudos