Re: converting string to datetime



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


.



Relevant Pages

  • Re: Convert MDB to ADP
    ... What I would suggest, then, is to use a dynamic record source for your form. ... > strings rptCtry() ... Is it possibel to find any function in SQL server to replace Format, ...
    (microsoft.public.access.adp.sqlserver)
  • Re: mm/dd/yyyy format question
    ... I was not talking about how .Net or SQL Server stores date/time values ... I get the impression that you are talking about ISO 8601 in terms ... applications use the format for unambiguously representing date/time ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Querying on dates in dd/mm/yyyy hh/mm/ss format using Access2002 And SQL Server 7
    ... For parsing a string to a date/time, the 103 format doesn't limits the user ... > which is used as the row source for the results form). ... > other solutions assuming I have to use SQL Server 7? ... > I don't understand how I can use parameterized stored procedures to solve ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Moving a VBA function to SQL server
    ... "String Functions " in Books Online. ... The SQL server database contains a table named 'WorkOrders'. ... This will produce a job header formatted like this: ... The format he specifies is stored in table 'Settings' - field 'JobHdrMask' ...
    (comp.databases.ms-access)
  • Re: Convert MDB to ADP
    ... There's nothing in SQL Server that directly replace the Format() function. ... About the closest you get is STRto convert numbers to strings, ... The only slight changes would be things like single-quotes ...
    (microsoft.public.access.adp.sqlserver)