Results 1 to 3 of 3

Thread: Views

  1. #1
    Join Date
    Aug 2003
    Posts
    328

    Unanswered: Views

    I am creating a view and I have a date field that is in a number string. Example: 20030725. Is there a way to use CONVERT(datetime, CAST(my_date AS varchar(8))) AS MY_DATE during design time? Right now I can only convert the string at run time.
    Thanks.

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Views

    Originally posted by exdter
    I am creating a view and I have a date field that is in a number string. Example: 20030725. Is there a way to use CONVERT(datetime, CAST(my_date AS varchar(8))) AS MY_DATE during design time? Right now I can only convert the string at run time.
    Thanks.
    Depends on your date format you could try something like this:

    select cast(left(cast(my_date as varchar),4)+'/'+
    substring(cast(my_date as varchar),5,2)+'/'+
    substring(cast(my_date as varchar),7,2) as datetime)

  3. #3
    Join Date
    Aug 2003
    Posts
    328

    Re: Views

    I figured it out.
    Thanks for your help.
    Last edited by exdter; 12-12-03 at 11:31.

Posting Permissions

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