I try to run this query using the where clause with the strfulldate. If I enter the date in the query as '2019-02-19' the query will return the record fine. If instead I enter in the where clause the strfulldate, although it returns the right date in the log, the query does not return any record, what am I doing wrong?
PHP Code:
lastyear = dateadd("YYYY", -1, Now())
strYYYY = DatePart("yyyy",lastyear)
nextmonth = dateadd("m", +1, Now())
strMM = Right("0" & DatePart("m",nextmonth),2)
strDD = Right("0" & DatePart("d",Now()),2)
strfulldate = strYYYY & "-" & strMM & "-" & "12"
hs.WriteLog("Error", "ERROR: Exception in script: " & strfulldate )
the value is returned as of 2019-02-19
Dim conn1 As MySqlConnection
Dim myCommand1 As New MySqlCommand
conn1 = New MySqlConnection()
conn1.ConnectionString = "Server=192.168.0.14; port=3306; Database=HomeAutomationDB; User ID=xxxxxxx; Password=xxxxxxx"
myCommand1.CommandText = "SELECT cycleymd, meterinitialreading, meterendreading, consumption, costcycle, datecreated, lastUpdated FROM metercycle Where meterid = 60675011 and cycleymd = 'strfulldate' ORDER BY meterid DESC LIMIT 1"
Comment