2

I'm trying to run a simple query.

  SELECT power_output.*
  FROM power_output
  WHERE t_stamp BETWEEN '{StartDate}'
  AND t_stamp '{EndDate}'

I'm getting the following error:

Incorrect syntax near 'Mon Jan 11 00:00:00 EST 2016'

I'd like it to return 'mm/dd/yyyy'

jackrabb1t
  • 14,609
  • 1
  • 21
  • 20

2 Answers2

3

The correct syntax is:

 SELECT power_output.*
 FROM power_output
 WHERE t_stamp BETWEEN '{StartDate}' AND '{EndDate}'

Column is only declared once see BETWEEN

connectedsoftware
  • 6,987
  • 3
  • 28
  • 43
  • Thank you for your response. I removed the second t_stamp and the error I get now is: Conversion failed when converting date and/or time from character string. – Jason Baldridge Jan 11 '16 at 22:47
2

You don't need to specify the column after the between x and x.

This will work:

 SELECT power_output.*
  FROM power_output
  WHERE t_stamp BETWEEN '{StartDate}' AND '{EndDate}'
Phiter
  • 14,570
  • 14
  • 50
  • 84
  • Thank you for you response. I removed the second t_stamp and the error I get now is: Conversion failed when converting date and/or time from character string. – Jason Baldridge Jan 11 '16 at 22:39
  • Try this http://stackoverflow.com/questions/14119133/conversion-failed-when-converting-date-and-or-time-from-character-string-while-i – Phiter Jan 11 '16 at 22:41