SQL Cast/Convert

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougancil
    Contributor
    • Apr 2010
    • 347

    SQL Cast/Convert

    I have the following bulk insert command on my asp.net page:

    Dim sqlQueryText As String = _
    "BULK INSERT dialerresults " + _
    "FROM '" & SavePath & "' " + _
    "WITH ( FIELDTERMINATOR = ',' , ROWTERMINATOR = '\n' )"

    and the following dataset that's being uploaded to a database:

    ,512 408 1323,steve miller,doctor stevens,2010070 9 1:30, 20100709 1:30,,

    You can see that there are two datetime fields. What I need to do is to convert the first datetime field to just date and the second one to just time. I'm using SQL 2000 and just need to know the proper syntax to do this to add it to my asp.net page.

    My database field names are as follows:

    ID (primary key )
    Phone
    PatientName
    DrName
    ApptDate
    ApptTime
    CurrentDate (timestamp)
    Result (null)

    Thank you,

    Doug
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    SQL Server does not have a date only datatype nor a time only datatype.Just datetime and smalldatetime. If you still want to, you can store them as numbers or nvarchar and handle the conversion as necessary.

    Good Luck!!!

    ~~ CK

    Comment

    • dougancil
      Contributor
      • Apr 2010
      • 347

      #3
      CK,

      Perhaps I didn't make my post clear enough. I understand that there aren't date and time within SQL but what I mean to say is that I want to use convert to truncate the datetime columns to show just date and time.

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        If you need to display it, you might want to consider handling it on your front-end instead. But if you really want your server to handle it, check out the third parameter of the CONVERT() function.

        Happy Coding!!!

        ~~ CK

        Comment

        • dougancil
          Contributor
          • Apr 2010
          • 347

          #5
          CK,

          I don't need to display it, but what I'd like to do is to just throw the convert statement into my asp.net page with the sql bulk insert. I've read the documentation but there doesn't seem to be a way to convert datetime to anything. The value I would be getting the datetime in, I just want to truncate it. The value is already set as datetime in that column. Is that possible?

          Comment

          Working...