CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Invalid date when submitting your sitemap to Google

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    19
  • Date Created
    Thursday, September 30, 2010
  • Last Updated
    Wednesday, November 17, 2010
  • This Article Has been Viewed
    1695 times
  • Short Desc
    Submitting a sitemap to google using the <lastmod> attibute you may get an Invalid date error if your format is not done correctly.
  • Details
    To make a valid <lastmod> date and time format for your Google Map, it must have the following attributes
    2010-09-30T10:20:58+00:00
    (or)
    2010-09-30 (This is just the date, without the time as shown above)
  • Recreate Issue
    To recreate the issue, here are a few examples.

    2010-09-30 10:20:58
    2010-09-30 T10:20:58+00:00
    2010-09-30 T 10:20:58 + 00:00
    2010-09-30T 10:20:58 +00:00
    2010-09-30T10:20:58+ 00:00
  • Resolve Issue
    To do this in ASP Classic, you will do the following.

    <%
    Set getCat = CreateObject("ADODB.Command")
    getCat.ActiveConnection=objConn
    getCat.Prepared = true
    getCat.commandtext="SELECT ID, convert(varchar(11),MDate,121) as MDate, CONVERT(CHAR(8), CONVERT(DATETIME, MDate, 113), 114) AS MilTime FROM MyTable"
    set rsgetCat = getCat.execute
    %>


    This in your sitemap code

    <%
    <lastmod><%if not IsNull(rsgetCat("MDate")) then%><%=replace(rsgetCat("MDate")," ","")%>T<%=replace(rsgetCat("MilTime")," ","")&"+00:00"%><%else%><%=date()&"T"&time()&"+00:00"%><%end if%></lastmod>
    %>


    In the above, we are making sure that the field if NOT NULL, if it is not IsNULL then display the data and time, if it is Null, then dislap the current date and time in the correct format.

    You want to make sure that there is not empty spaces in the data and time, so we use a replace() function to get rid of any and all spaces.