The dates stored in the database are like 3/1/2021 as smalldatetime
But I'm asking to compare against 2021-03-01, an ISO date, so wrap what I'm asking to compare to.
I came up with this ...
$query = "
FROM project as a, commission_summary as b
WHERE a.project_no = b.project_no
AND (a.sold_date <= '$lastDate')
AND (a.status = 'construction' or a.status = 'finished')
AND (convert(CHAR(10), b.startup_check_date, 120) BETWEEN '$firstDate' AND '$lastDate')
AND a.sales_no = '$salesId'";
I fiddled with the conversion, and was sure I got it right but it failed. Then I used the suggestion to wrap the dates in single quotes and it produced a clean result of 9.
I get the convert part, declare a CHAR no more than 10, input value, ?
Not sure what the 120 stands for.
However your explanation of the date formats has schooled me in how to fiddle with them and get it right.
Just FYI, I wrote some other fixes earlier that are similar, and just had a complete blackout of my previous experiences. But this lesson should solidify it. Thanks!
If it ain't broke don't fix it
Discover my world at jkirkerx.com
I am not sure why you are converting to CHAR(10) when you are looking for a date comparison/
What you are converting is your b.startup_chack_date value. If that is already a date then it does not need converting.
For the meaning of the 120 (and other values) see, for example, <a href="https://www.w3schools.com/SQL/func_sqlserver_convert.asp">[^]
for (int i = 0; 1< dataGridViewMotor1.Rows.Count - 1; i++)
Your compare expression is still wrong. The expression 1 < dataGridViewMotor1.Rows.Count - 1 will always be true. It should be i < dataGridViewMotor1.Rows.Count.
And a suggestion: don't rely on videos to teach you how to program. Get a good online tutorial, or book, and learn the actual language first. Using Windows forms and complex controls without understanding the structure of the language properly is a waste of your time.
I need some general advice. (My natural language is Portuguese).
I need to do a small Windows desktop application to fill (by hand) a single table with, say, a maximum of one thousand records of some 20 fields for later manipulation.
About 15 years ago I have done a database application in Access 2003 whose tables were separately stored (same folder) without a SQL server. I would like to stay away from Access and use Visual Studio Community and, also, stay away from a SQL server or the need to have it installed in the computers where the application will run.
I suppose that to crate a table in a form must not be complicated (I have already played a little bit with that) but I am at a lost about storing the table on disk without SQL database/server. All examples I found in the Web involve SQL servers.
Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable because importing some data from excel could eventually be interesting. The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application.
At the moment I am flying around without a place to land. Any help would be greatly appreciated.
I have been fighting Visual Studio for a couple hours and managed to create the basic GridView configuration. Although in the much simpler Arduino environment, I am familiarized with C and I have recently written a couple Classes ( I should have started before ). Nevertheless helped by some web browsing I suppose I can handle the code behind the forms.
I decided to leave Excel for later and concentrate in creating and reading CVS files.
Then EPPlus or LinqToExcel might be more suitable.
I want to make a server and client side WITSML (for Oil & Gas Wells Drilling Data Send/Receive). There are some SDKs here: (WITSML api library for .Net / C# client apps?). I surfed though the internet, but i have not been found any code example or guide to use them.
==>.Are There any code example to develop a WITSML and/or WITS server and Client side software in C#?
Thank you in advance.