Basically I selecting records between plus or minus 60 days from current datetime now. I am using an access database for current project. I just need help with current where clause in green.
Select firstName, lastName, CreatedDateTime
FROM ExampleTable
Where
CreatedDateTime >= DateAdd(""d"",Now(),-60) AND CreatedDateTime <= DateAdd(""d"",Now(),60)
VulpesPosted Sep 2, 2012, 9:15 AM
1 . Use single quotes.
2. Use double quotes escaped with a backslash as Sukesh has done.
3. Use a verbatim string and double the double quotes:
string sqlDateFilter = @" CreatedDateTime >= DateAdd(""d"", -60, Now()) AND CreatedDateTime <= DateAdd(""d"", 60, Now())";
VulpesPosted Sep 3, 2012, 12:02 PM
TempYear = DateTime.Now.AddMonths(-6).Year;
FiscalYearStart = "7/1/" + TempYear;
FiscalYearEnd = "6/30/" + (TempYear + 1);
StrFilter += "ServiceDateStart >= #" + FiscalYearStart + "# AND ServiceDateStart <= #" + FiscalYearEnd + "#";
David SmithPosted Sep 3, 2012, 11:41 AM
David SmithPosted Sep 3, 2012, 11:29 AM
If Month(Now()) < 7 Then
Sukesh MarlaPosted Sep 2, 2012, 6:20 AM
Try this
Check this is correct answer if it helped.
David SmithPosted Sep 2, 2012, 4:52 AM
string sqlDateFilter = " CreatedDateTime >= DateAdd(''d'',Now(),-60) AND CreatedDateTime <= DateAdd(''d'',Now(),60)";
VulpesPosted Sep 2, 2012, 4:14 AM