Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2007
    Location
    Auckland New Zealand
    Posts
    120
    Provided Answers: 1

    Unanswered: Formatting Dates for Google Sitemaps

    I have a SPROC which Im using to get data into a datatable (.NET) for creating an XML sitemap file, I found some SQL code for formatting the date but isn't working correctly:

    (SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS '[YYYY-MM-DD]') AS lastmod,

    Ive also used this against other smalldatetime values in Union all queries,

    it should rather obviously be 2008-11-03 and end up in the XML as
    <lastmod>2008-09-28</lastmod>

    but its ending up in the file as <LastMod>11/02/08</LastMod>
    this information is coming directly from SQLServer, as I don't touch the dates in the application layer, and use the datatable.writexml method.


    Actual Output from SPROC

    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2
    11/03/08 daily 0.2



    any help would be appreciated, don't want to have to fiddle around with the dates in the application layer, as the writexml method makes life alot easier, granted I can get this correct,

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    you're converting the date into style 1, which is yyyy-mm-dd

    Check this link: http://doc.ddart.net/mssql/sql70/ca-co_1.htm
    George
    Home | Blog

Posting Permissions

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