Jump to content
rhysdunn

Create Date Range Parameters in Excel SQL

Recommended Posts

I have written a SQL Query for my Database at work in Excel so that I can automatically update it. Took me a while to figure out the date sections and getting it to return just the current date with the below code.

 

 

WHERE
f.FolioStatusId in (1, 7, 8, 9, 13)
AND cast(f.made_on as date) >= cast(getdate() as date)
What I'd like to do is to have a section in Excel where I can type the Dates that I need the data from and too.
I know that I can insert a "?" in the query section to make a cell reference but cant figure out what code would need to go in the WHERE section to do that.
Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites

You may be able to format the cells in Excel to show the date as you like, but Microsoft has a habit of making things human-readable instead of useful for things like a database.

Share this post


Link to post
Share on other sites

I've formatted as a date but the error i get is as below

 

[Microsoft][ODBC SQL SQL Server Driver]

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

 

I've formatted though which is the strange thing

Share this post


Link to post
Share on other sites

Apparently you're using a string for the data, you might need to explicitly cast or convert it to a date.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...