Re: converting string to datetime
- From: "Patrice" <http://www.chez.com/scribe/>
- Date: Wed, 19 Dec 2007 10:44:18 +0100
Or even why to return a string at all ? My personal preference would be to
always return a date from SQL Server. Then the date is formatted client side
for display (what if you display those data in a grid and want to sort them
by date ?)
--
Patrice
"(O)enone" <oenone@xxxxxxxxxxx> a écrit dans le message de news:
UyX9j.12127$ov2.7141@xxxxxxxxxxxxxxxxxxxxxxx
zino wrote:
I need to convert a string as: "DEC 18 2007 2:49:40:783PM"
to a date. This value is sent by SQL server as :select
convert(varchar(30), creationDate, 109) from ... ... .
Just one question: why don't you get SQL Server to return the date in
ISO8601 format instead? This is the only globally identifiable
non-ambiguous format in which dates can be represented as strings.
You can get SQL Server to return it in this format by changing the 109 in
your convert statement to 21 instead. (I <3 magic numbers....)
Then you can just use DateTime.Parse or CDate to convert the string to a
date.
HTH?
--
(O)enone
.
- References:
- Re: converting string to datetime
- From: \(O\)enone
- Re: converting string to datetime
- Prev by Date: Re: System.InvalidCastException: QueryInterface for interface ...
- Next by Date: Re: "Open with" question
- Previous by thread: Re: converting string to datetime
- Next by thread: Re: converting string to datetime
- Index(es):
Relevant Pages
|