I am trying to set up a query that will select values before the first day of the current month and the last day 2 months ago. Essentially getting all the records for the previous month. I am trying to use the DateSerial, and I can get all records before the first day of the current month but when I add in the part for the greater than the last day 2 months previouos it does not return any records.
Can anyone see what I'm doing wronng?
This works fine excluding the current months records:
SELECT AssetCenterImport.[Remarks (Problem)], AssetCenterImport.[Notified On]
FROM AssetCenterImport INNER JOIN T_InventoryBilling ON AssetCenterImport.SerialNo = T_InventoryBilling.IB_SerialNumber
WHERE (((AssetCenterImport.[Notified On])>Format(DateSerial(Year(Now()),Month(Now()),1),"m/d/yyyy")));
this returns no records:
SELECT AssetCenterImport.[Remarks (Problem)], AssetCenterImport.[Notified On]
FROM AssetCenterImport INNER JOIN T_InventoryBilling ON AssetCenterImport.SerialNo = T_InventoryBilling.IB_SerialNumber
WHERE (((AssetCenterImport.[Notified On])>Format(DateSerial(Year(Now()),Month(Now()),1),"m/d/yyyy") And (AssetCenterImport.[Notified On])<Format(DateSerial(Year(Now()),Month(Now())-1,1)-1,"m/d/yyyy")));
When I run the DateSerial part in the debugger it returns the desired date.
Can't figure it out.
Can anyone see what I'm doing wronng?
This works fine excluding the current months records:
SELECT AssetCenterImport.[Remarks (Problem)], AssetCenterImport.[Notified On]
FROM AssetCenterImport INNER JOIN T_InventoryBilling ON AssetCenterImport.SerialNo = T_InventoryBilling.IB_SerialNumber
WHERE (((AssetCenterImport.[Notified On])>Format(DateSerial(Year(Now()),Month(Now()),1),"m/d/yyyy")));
this returns no records:
SELECT AssetCenterImport.[Remarks (Problem)], AssetCenterImport.[Notified On]
FROM AssetCenterImport INNER JOIN T_InventoryBilling ON AssetCenterImport.SerialNo = T_InventoryBilling.IB_SerialNumber
WHERE (((AssetCenterImport.[Notified On])>Format(DateSerial(Year(Now()),Month(Now()),1),"m/d/yyyy") And (AssetCenterImport.[Notified On])<Format(DateSerial(Year(Now()),Month(Now())-1,1)-1,"m/d/yyyy")));
When I run the DateSerial part in the debugger it returns the desired date.
Can't figure it out.