Writing a date and time into an xml attribute with the DateTime datatype

How do you write date and times into an attribute with a datetime databype? 
I tried:
<NewsArticle Date="2008-05-11 11:20:00 AM">

But the schema generated from the xml file says the Date attribute is a 
string. Then I tried:

<NewsArticle Date = 2008-05-11 11:20:00 Pm>

Again, this didn't work because the conversion program complained and told 
me there was a parser error because there weren't quotes or apostrophes 
around the date string. How do I fix this?



0
a_borka (15)
8/26/2008 1:54:32 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
790 Views

Similar Articles

[PageSpeed] 14

Andy B wrote:
> How do you write date and times into an attribute with a datetime databype? 
> I tried:
> <NewsArticle Date="2008-05-11 11:20:00 AM">

Use the methods the XML APIs provide e.g.
         writer.WriteStartElement("NewsArticle");
         writer.WriteStartAttribute("Date");
         writer.WriteValue(DateTime.Now);
         writer.WriteEndAttribute();
         writer.WriteEndElement();
gives e.g.

<NewsArticle Date="2008-08-26T12:40:17.890625+02:00" />


> But the schema generated from the xml file says the Date attribute is a 
> string. 

I am not sure however the inference will try to infer an xs:dateTime 
value but you can try that yourself.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
8/26/2008 10:42:39 AM
Got it.

"Martin Honnen" <mahotrash@yahoo.de> wrote in message 
news:e%23uK6h2BJHA.1628@TK2MSFTNGP03.phx.gbl...
> Andy B wrote:
>> How do you write date and times into an attribute with a datetime 
>> databype? I tried:
>> <NewsArticle Date="2008-05-11 11:20:00 AM">
>
> Use the methods the XML APIs provide e.g.
>         writer.WriteStartElement("NewsArticle");
>         writer.WriteStartAttribute("Date");
>         writer.WriteValue(DateTime.Now);
>         writer.WriteEndAttribute();
>         writer.WriteEndElement();
> gives e.g.
>
> <NewsArticle Date="2008-08-26T12:40:17.890625+02:00" />
>
>
>> But the schema generated from the xml file says the Date attribute is a 
>> string.
>
> I am not sure however the inference will try to infer an xs:dateTime value 
> but you can try that yourself.
>
> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/ 


0
a_borka (15)
8/26/2008 11:07:53 AM
Reply:

Similar Artilces:

How to link Excel deadline dates to Outlook?
Need to link dates to Outlook users in either email or tasks, for purpose of task reminders and to track completion of task. ...

sorting dates in Excel 97
Running a worksheet that lists all medical expenses and am not able to always insert date, expense, who to, in correct sequence. Some postings just come in on time. Is there a sort formula that will allow me to sort these entries in sequence? Will the sorting move up the entire row that lists date, amount, payable to, etc. also? Thank you, Steve T. I wouldn't use any formulas for this. I'd select the range (all the columns in that range, plus the last row of headers, plus all the data) and do Data|Sort If you include all the columns that should move with the sort, you'll ...

Customer Time Zones
Has anyone had the need to know a customer's time zone in mscrm? Wondering what is the best way to determine this, so csr's don't call overseas customers in the middle of the night! Chris CRM already has an attribute for storing the time zone, called address1_utcoffset - it just isn't on the account form by default. If you put it on the form, it displays a picklist of all the time zones "Chris Patten" wrote: > Has anyone had the need to know a customer's time zone in mscrm? > Wondering what is the best way to determine this, so csr's don't call...

Write
I am trying to change the default margins. I am requested to use the Write mode to do this. What is Write, and how do I access it? Are you using voice recognition? Margins are simply changed in the Arrange Menu in Publisher. Are you in the right newsgroup? -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "CBC" <anonymous@discussions.microsoft.com> wrote in message news:183bb01c44a40$107bd5d0$a501280a@phx.gbl... > I am trying to change the default margins. I am requested > to use the Write mode to do this. W...

Is there a way for Windows Service to Read/Write HKCU Reg key ?
Hi: I'm writing a Windows Service program which needs to read/write the HKEY_CURRENT_USER registry key for the current logged on user. I know that for a Windows service does not have concept of HKCU since it is always running in SYSTEM's context. But is there a way (trick?) for a service to access the HKCU registry key? Thanks In Advance ! Polaris Hello Try, from a user application (the one that is logged on, or the current user), to send the services the user's SID. Then access the HKCU through HKEY_USERS\users_sid\............ Hope that helps, Elias "Polaris&qu...

Date format #3
I have two sheets that includes the date m/d/y which is to be transferred to the second sheet. If a date isnt entered on the first sheet I want it show as blank on second sheet. Right now it is showing 1/0/00. how can I change this? Thanks Hi Wally try the following fomule on your second sheet =IF('sheet1'!A1="","",'sheet1'!A1) -- Regards Frank Kabel Frankfurt, Germany Wally wrote: > I have two sheets that includes the date m/d/y which is to be > transferred to the second sheet. If a date isnt entered on the first > sheet I want it show as...

wrong received times in outlook
I have two systems running Outlook 2002 that will show a received time two hours prior to the time that the messages was actually received. An email is received at say 10:30 am and it will show a received time of 8:30 am in the outlook window. There is only one time zone set up by default when the software was installed. Any fixes? ...

Writing formula for excel worksheet
Item Rate1 Rate2 Rate3 A 3 4 6 B 8 5 23 C 56 5 78 Above is my excel sheet. I want to write some formula so that in every row cell having minimum rate should come bold. Like For Item A - Rate1(3) for Item B - Rate2(5) For Item C - Rate2 (5) There may be a neater way but this works. Somewhere in you sheet in a cell type =min(A1:a4), I used L1 Change this to watever range you are trying to evaluate. Then select this range and click format - conditional format - cell value - is equal to =($L$1) and apply your bold font. The lowest value in the range will then become bold. Mike "Gaur...

How to know witch are the weekend days between two dates
I have to make a list of every weekend days between two dates. Example (dd/mm/yyyy): Field1: 01/01/2007 Field2: 15/01/2007 The result (on a listbox) I want are all the weekend days between those dates: 06/01/2007 07/01/2007 13/01/2007 14/01/2007 Any help? Assuming i have two fields on a form that contain the beginning and ending dates (FirstDay, LastDay), a listbox (list0) and a command button to compute them, the code would looke like this. Private Sub Command2_Click() Dim strday As String Dim intIndex As Integer Dim intNbrDays As Integer Dim newdate As Date List0.RowSource = "&q...

Using XSLT to Append Attributes to an XSD File
I wrote an application to scrape a database and create an XSD file which will be annotated by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation using XSLT. Here is background on Typed DataSet: Using Annotations with a Typed DataSet http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingAnnotationsWithTypedDataSet.asp I need to append an attribute a specific XML node. Change <xs:element name="column_1" msdata:ReadOnly="true" minOccurs="0" type="xs:short" /> ...

CONDITIONAL FORMATING DATES
How do I highlight a cell that has a date older than 7 days from todays date? ex. column G has the date I passed out the invoice to be signed off on. I want to highlight all those that have been out for more than 7 days. I tried Formula is =G:G<TODAY()-7 but that highlights every date no matter if it is older than 7 days or even future dates. If I want it to look really nice I would like it to highlight the entire row that date fall in. Hi Mark the whole range of data you want to format. With the cursor in cell G1, Format>Conditional Formatting>Formula Is =TODAY()-$G1>7 S...

XSLT: Creating anchors from outer XML files
Hi, I'm trying to put the links (href attribute of the <a> element) out of my XSLT files, in a XML file, and read it from the stylesheet. I suppose that I have to use the document() function to link to the XML file containing the URLs, but I don't know how to do it. I've tried something like this: This is XML file containing the URLs (link.xml): <?xml version="1.0" encoding="utf-8" ?> <LINKS> <L1> /SomePage.aspx </L1> </LINKS> And this is the code from the stylesheet: <a href="{document('link.xml')/L...

write protect/write redirect/kios mode
Hey, I LOVE snapshots in virtualmachines and think it would be awesome to have something like this for my main windows install. Anyone know of any hardware/software to redirect writes to another drive/file/memory/hardware? Or hardware to write protect a drive for kios's (i found some once befor the reverted all changes on shutdown, but cant find it anymore ><) I know VSS(virtual shadow copy service) has a function to redirect on write and wondering if i might be able to use that :/ It will just make everything cleaner, and give alot of flexiblity to setting up ...

Cannot write to memory location
I can not (all of the sudden) run Publisher in the last week. When starting to run it, I get that it cannot write to a certain memory locaiton, so it is shutting down. I need to get this program working. I have read through this forum and tried the different fixes as well as the knowledge base (emptied the temp file, disabled anti-virus, etc.) but it still won't work. An example is: "The instruction at "0x77f585c0" referenced memory at "0x00000000". the memory could not be "written". Click on OK to terminate the program." The header read...

Time Formatting #2
Is there any way to format time to AM/PM without displaying AM/PM? Thanks. -- Brian Try the 24 hour clock Format>cells>time>13:30 "brianwakin" wrote: > Is there any way to format time to AM/PM without displaying AM/PM? Thanks. > -- > Brian The time needs to be displayed in a 12 hour clock format without the "AM or PM" actually being displayed. Is there any way to do this? Thanks again. -- Brian "Ray A" wrote: > Try the 24 hour clock > Format>cells>time>13:30 > > "brianwakin" wrote: > > > ...

Julian date 02-26-08
Can you create a pop up calendar that shows both the Julian and Gregorian date in the same day box? This newsgroup supports the use of Microsoft Access, the relational database application. Is your question about MS Access? (by the way, I believe there may be more than one version of "Julian" dates .... how are you defining this term?) Regards Jeff Boyce Microsoft Office/Access MVP "Shari" <Shari@discussions.microsoft.com> wrote in message news:779FF63A-BF4F-4584-A160-2662A7A811DE@microsoft.com... > Can you create a pop up calendar that shows both the J...

Recover a mailbox from a user where exchange attributes removed
I have a user I removed her exchange attributes, I just found out she didnt copy her exchange mailbox offline. Is there an easy way to get her mailbox? If I reset her exchange attributes will it create a new mailbox? I would like to recreate her account with mailbox intact if possible. I do have backups with the bkexec excjhane agent if that is needed. server is exchaneg 2003 thanks craig Hi Craig, How long ago was this done? If you still have mailbox retension enabled the mail attributes where not removed any more than 30 days ago and you have not purged the mailbox from Excha...

two variable dates created from a single date
Me: total newbie, in a hurry. please tell me how, THANKS! User enters a date in column A (m/d/yy). Formula in column B needs to show column A date plus 60 days (m/d). Formula in column C needs to show column A date, minus whatever # of days until 1st day of that month, then plus one year (m/1/yy). e.g., 2/1/08 (column C) derived from user entry 2/17/07 (column A) in column B, try =A1+60 formatted as m/d in column C, try =DATE(YEAR(A1)+1,MONTH(A1),1) "Lindsay" wrote: > Me: total newbie, in a hurry. please tell me how, THANKS! > > User enters a date in column A (m/d/...

Split Database Slow response time
Small database, small tables, few users. B4 tables and forms,reports all in the same database;response time 1-3 seconds. After split(tables in separate DB) and link to tables from application DB; slooooooooooow. 30-45 seconds vs 1-3 seconds. Both before & after Data and Apps on a network server. Is there some parameter that can be set to not pay the Linked file response time penalty? If I'm interpreting your description correctly, you have the application (front-end) AND the data (back-end) both located on a network server. This would mean that every time a user on a PC wants...

Missing date in preview pane
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: imap Hello there. <br><br>Is there any way to have in the preview pane the DATE displayed? Actually, it just displays: <br> Subject line <br> Sender <br> Recipient <br><br>Any help will be appreciated, thanks. <br> F. Hi, there is no way to change this. The date is only shown in the e-mail list, and you can toggle between the "preview pane on the right side" and "below the list" settings to see more details. Also, if ...

Search for current date in a text field
I have a SQL database that I have an external data link to an access database. I need to search records based on the current date. The problem is that the field that needs to be searched is in a text format "yyyy-mm-dd". I have used the following statement successfully to pull out current year: Left([ArrestDate],4)=DatePart("yyyy",Date()). This does pull off any records with the 2010 year. However, I need to sort by the entire date. How can I do this? I have tried the following hoping it would put a string together but I get an "Invalid Procedure Ca...

How do I sort e-mails by sender and then by date?
I want to be able to sort e-mails by sender, which I can do, and then, at the same time, have the e-mails by one sender arranged in chronological order according to date sent. One of the ways you can group mail items in OL2003 is just what you're mentioning. If you group by From, the messages are sorted by date within the group "kamtree" <kamtree@discussions.microsoft.com> wrote in message news:9C4B3305-6C96-4B7B-B904-CB8A4AE1CEDA@microsoft.com... >I want to be able to sort e-mails by sender, which I can do, and then, at >the > same time, have the e-mails...

how do I do a Planned vs Actual start date & end date graph
hi, I'm plotting a Phase of a project in Excel and need to capture Planned vs Actual Start dates and End dates- how do I go about doing this in Excel using graphs? - please advise, thanks. ...

Negative dates and times
I need excel to display negative times. At present cells display #######. Can I change this? Thanks Gavyn Hi Gavyn, I think you have to use the 1904 date system. Go Tools menu > Options... command > Calculation tab > Select 1904 date system. But, if your workbook has links to other workbooks that use the default 1900 date system, it could cause erroneous results. HTH --- Orlando Magalh´┐Żes Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email) "Gavyn Milton" <gavyn.milton@damovo&g...

Change date of many mails in the exchange database
Hello Our exchange server had its date changed for an unknown reason (ntp problem it seems) to 2014 ! All the mails that arrived while the date was incorrect are now tagged as received in 2014, and then are always at the top of the mailbox's users, it's a big problem as the users need all theirs mails correctly ordered on date. Is it a way to correct this on all the emails? automatically? or even manually? Thanks a lot for your help ! Cheers On 18 avr, 08:20, mkso...@hotmail.com wrote: > Hello > > Our exchange server had its date changed for an unknown reason (ntp > pr...