October 4, 2018 at 7:24 am
the syntax working with fixed date and time
SELECT LAST_UPDATED_TIMESTAMP FROM WORKING_HRS WHERE LAST_UPDATED_TIMESTAMP between '2018-10-02 06:00:00' and '2018-10-03 06:00:00'
Dynamic date range after convert datetime function not fetching
SELECT LAST_UPDATED_TIMESTAMP FROM WORKING_HRS WHERE LAST_UPDATED_TIMESTAMP convert(datetime,GETDATE()-2,'06:00:00') and convert(datetime,GETDATE()-1,'06:00:00')
Error - Argument data type varchar is invalid for argument 3 of convert function.
October 4, 2018 at 7:45 am
What is your question?
'06:00:00' is not a valid argument 3 for CONVERT, the error message is clear.
October 4, 2018 at 7:45 am
SQL Galaxy - Thursday, October 4, 2018 7:24 AMthe syntax working with fixed date and time
SELECT LAST_UPDATED_TIMESTAMP FROM WORKING_HRS WHERE LAST_UPDATED_TIMESTAMP between '2018-10-02 06:00:00' and '2018-10-03 06:00:00'Dynamic date range after convert datetime function not fetching
SELECT LAST_UPDATED_TIMESTAMP FROM WORKING_HRS WHERE LAST_UPDATED_TIMESTAMP convert(datetime,GETDATE()-2,'06:00:00') and convert(datetime,GETDATE()-1,'06:00:00')Error - Argument data type varchar is invalid for argument 3 of convert function.
The third argument in the convert should be the Date and time style - it has no idea what you mean by '06:00:00'. You can find the list of integers used for the styles in the documentation for Cast and Convert:
CAST and CONVERT (Transact-SQL)
Sue
October 4, 2018 at 7:53 am
Furthermore, GETDATE() returns DATETIME, so converting from DATETIME to DATETIME is an identity operation.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy