smalldatetime in SQL????

Results 1 to 2 of 2

Thread: smalldatetime in SQL????

  1. #1
    Join Date
    Dec 1969

    Default smalldatetime in SQL????

    I'm using a calendar control to select a date via:, and when submitted to the SQL database, there's no time included, but when retreiving the record, it's giving me a time. I thought there was a workaround, but because I need to use the datetime or smalldatetime in SQL to add/subtract days..I'd really rather not make the code more difficult than it has to be. Anyone know what I should really be doing here?

  2. #2
    Join Date
    Dec 1969

    Default SQL Server doesn't have...

    ...and nice simple function to grab just the date from a datetime value. Access and VBS have DateValue( ) but no such luck in TSQL.<BR><BR>One good way:<BR><BR>SELECT CONVERT( DATETIME, CONVERT( VARCHAR, yourDateTimeField, 102 ), 102 ) AS dateonly<BR><BR>The "102" conversion number results in a date-only string, which you then convert right back to a datetime value.<BR><BR>(You can leave it as a string if you don&#039;t need it for things like ORDER BY.)<BR><BR>If you don&#039;t NEED to get the date only in TSQL--if you can do that in the VBS code instead--then just use DateValue() in the VBS code.<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