rhysdunn Posted December 7, 2015 Share Posted December 7, 2015 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! Link to comment Share on other sites More sharing options...
rhysdunn Posted December 7, 2015 Author Share Posted December 7, 2015 Time in the Database is HH:MM:SS But The issue I find in excel is that it puts it with a PM which the system wont recognise Link to comment Share on other sites More sharing options...
justsomeguy Posted December 7, 2015 Share Posted December 7, 2015 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. Link to comment Share on other sites More sharing options...
rhysdunn Posted December 8, 2015 Author Share Posted December 8, 2015 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 8, 2015 Share Posted December 8, 2015 Apparently you're using a string for the data, you might need to explicitly cast or convert it to a date. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now