SQL greater than Date

Raanan

Board Regular
Joined
May 22, 2013
Messages
122
Hi, Im hoping you can help a little..

Im trying to pull data from an Access database based on "date completed" being this year, using SQL.

Im using:
Select ....
FROM ....
WHERE [Date Completed] > '20150101'

however Im getting data mismatch.

Ive checked the Access and the date completed file is in the format Date/Time.

Ive tried different variations but cant get this to work. Any ideas?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
WHERE [Date Completed] >= #2015/01/01#

WHERE [Date Completed] >= DateSerial(2015,1,1)

WHERE CLng([Date Completed]) >= CLng(DateSerial(2105,1,1))
 
Upvote 0
It will depend a lot on the data type for the field [Date Completed]. If the datatype is date/Time then Fazza's suggestions will work.

Note: The suggestion will only work until for the current year and not past years.

I am suuing the field is a date/time data type.

If you want to be able to run this for any year then you could use:


Code:
 WHERE Year([Date Completed]) = ([enter4 digit  year])


for the current year


Code:
WHERE (Year([Date Completed]) = Year(Date()) )

Note: using Year() also remove any time (Like using Clng() )
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top