3

Can anyone explain the correct usage/requirement of using these '#' number signs. Do they simply have to surround any date type in SQL?

Thanks

SELECT * FROM Orders
OrderDate BETWEEN #07/04/1996# AND #07/09/1996#;
COOLBEANS
  • 729
  • 3
  • 13
  • 31
  • 1
    You didn't provide enough info. Your database engine is relevant as is the application where you saw this code. – Dan Bracuk Jan 25 '14 at 13:41
  • hash tags in MS SQL SERVER denote temp tables, but they wouldn't look like that (wrapping) pretty sure you are not talking SQL Server. – T McKeown Jan 25 '14 at 13:42
  • I got the code from the bottom of this popular SQL tutorial see http://www.w3schools.com/sql/sql_between.asp Si I guess it's just SQL? – COOLBEANS Jan 25 '14 at 14:20

2 Answers2

3

These are the MS Access syntax for date constants.

In most other databases, you just use a string to represent a date. In my opinion, you should use one of the ISO standard formats for this (either YYYYMMDD or my preference YYYY-MM-DD). So a valid date in most databases would be '2014-01-01'. In Access, this can be written #2014-01-1#.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

I suppose that is a vendor specific SQL modification. If I am not mistaken, that is specific for MS Access databases that the date should be delimited with a hash.

Aleksandar Stojadinovic
  • 4,851
  • 1
  • 34
  • 56