2

I recently ran across this:

SELECT { t '07:32:00' }

The return is 2017-05-22 07:32:00.000 (I'm using Sql-Server-2008)

If I don't include a proper time between the brackets, I get an error below:

Conversion failed when converting date and/or time from character string.

My question is; is this a "shortcut" for getdate() or some other similar function?

And, how can/should it be used?

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
Obfuscated
  • 311
  • 2
  • 15
  • They're ODBC escape characters. – Bacon Bits May 22 '17 at 12:47
  • @BaconBits, but why is the time expanded to a timestamp (incl today's date)? – jarlh May 22 '17 at 12:48
  • I'm sorry I didn't make clear...How it the "t" used and are there others? – Obfuscated May 22 '17 at 12:51
  • https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/date-time-and-timestamp-escape-sequences – jarlh May 22 '17 at 12:52
  • @jarlh Dunno. It doesn't return a timestamp on my SQL Server 2008 R2 system. `t` is the code for `time`, and that's a valid data type in SQL Server 2008. – Bacon Bits May 22 '17 at 12:54
  • Unfortunately, people were too quick to close your question, and I cannot provide an adequate enough answer in the comments. The duplicate question is not really answering the question you have. Anyhow, have a look at these two pages for explanation and reference: http://web.synametrics.com/winsqlescapeclause.htm and https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/odbc-escape-sequences – kojow7 May 22 '17 at 13:51

0 Answers0