Parsing date using sql

Results 1 to 3 of 3

Thread: Parsing date using sql

  1. #1
    DateMan Guest

    Default Parsing date using sql

    Can anyone parse dates in sql?<BR>Give me what you got!<BR>09/09/2000 10:39:00<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Parsing date using sql

    good question (!!). what are you trying to achieve exactly?<BR><BR>j

  3. #3
    Join Date
    Dec 1969

    Default SQL is a declarative language

    In general, you don&#039t parse (or otherwise do complex manipulation) in SQL. SQL is a declarative language, not an algorithmic one.<BR><BR>However, it is true that virtually every DB system out there has extended SQL (too often in mutually exclusive ways!) and certainly with the MS products you can write some moderately complex computational code.<BR><BR>The big problem is writing such code in a way that it can be used as a subroutine and/or so that you can store temporary results. Even with the MS variants, you will probably have to resort to stored procedures to do the tough stuff.<BR><BR>But now that we&#039ve said all that... Why in the world would you *want* to parse a date in SQL??? Presumably, once a date/time value is stored in a DB field you have no reason to parse it (not that you really could, meaningfully, already been parsed and converted to internal form). And if you have a date coming from "outside" (e.g., from an HTML form), then you&#039re a lot better off parsing it (presumably for the purpose of being sure it is a valid date or date/time?) before you try to store it in the database. After all, if you passed in an invalid date to a SQL-based parser, what could that parser do? Nothing but hiccup and issue an error! On the other hand, if you validate the date in (say) client-side JavaScript code, any invalid value won&#039t even leave the browser form before it is caught. And that&#039s a far better solution to ensuring that the user has a chance to correct errors in a date/time format value, no?<BR><BR>So if none of the above answers you, can you tell us what in the heck you *do* want to do?<BR><BR>

Posting Permissions

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