+ Reply to Thread
Results 1 to 2 of 2

Thread: SQLServer datetime field doesn't translate properly as javascript date object

  1. #1
    Dennis Akins
    Join Date
    Apr 2010
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default SQLServer datetime field doesn't translate properly as javascript date object

    I am reading a date value directly from a sqlserver table and trying to display the value as text in an info wondiw using javascript api. I can read the table, get the numeric value stored in the table, format the date into a useful string, and display the result. My problem id the date is always one day behind what it read from the table. Code snippet are:

    var info = feature.attributes.desc
    .
    .
    .
    + "<br />Report Date : " + formatDate(feature.attributes.reportDate);
    var template = new esri.InfoTemplate("", info);


    function formatDate(value) {
    if (value != null) {
    var inputDate = new Date(value);
    return dojo.date.locale.format(inputDate, {
    selector: 'date',
    datePattern: 'MM/dd/yyyy'
    });
    }
    else {
    return "null";
    }
    }


    Has anyone else experienced this problem? How can I fix this issue?

  2. #2
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: SQLServer datetime field doesn't translate properly as javascript date object

    This might be applicable: http://gis.stackexchange.com/a/20319/124

    Here's some code that might address your issue: http://jsfiddle.net/yEkjm/
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts