SQL Update / Date Time FORMAT

Results 1 to 3 of 3

Thread: SQL Update / Date Time FORMAT

  1. #1
    Join Date
    Dec 1969

    Default SQL Update / Date Time FORMAT

    I am writing a time feild to a SQL db,<BR>and I want the time formatted hh:mm...<BR>The feild data type is datetime...<BR>It is formatted correctly if I write with ADO<BR>But if I do and SQL update I get... m/d/y hh:mm:ss<BR>Tried Using SQL Conversing Functions,<BR>But SQL server tells me TO_DATE is not a valid function...<BR>Verry anoying

  2. #2
    Join Date
    Dec 1969

    Default Crosspost <eop>


  3. #3
    Join Date
    Dec 1969

    Default Try CONVERT (varchar, GETDATE(), 8)

    SELECT CONVERT (varchar, GETDATE(), 8)<BR>where GETDATE() is your date. <BR><BR>Keep the datetime field, just use CONVERT in your sql.<BR><BR>SELECT CONVERT (varchar, GETDATE(), 8)<BR>-OR-<BR>SELECT CONVERT (varchar, YourDateField, 8) from TableName<BR><BR>Here&#039;s a convoluted update example... Just an idea. You can just update the date or just the time. <BR><BR>insert into test values (cast(CONVERT (varchar, GETDATE(), 111) as varchar) + &#039; &#039; + cast(CONVERT (varchar, GETDATE(), 8) as varchar)) <BR><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