Date Syntax

creyn

Board Regular
Joined
Sep 16, 2016
Messages
127
Is this the proper syntax for date in Access?

Between #01/01/2016# And #01/31/2016#


If so, why does it continue to default to this when I run the query?

Between "#01/01/2016#" And "#01/31/2016#"


I am using Access 2013
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Is the field you are setting this criteria for a Date field?

Where are you actually putting/using this criteria?
 
Upvote 0
No, they have it set as a Short Text field. How can I use the Between #01/01/2016# And #01/31/2016#? Will I need to change the field to a date field?
 
Upvote 0
Rather than altering the table structure you could try using CDate to convert the field values from string to dates but ideally it should be a Date field.
 
Upvote 0
you also might want to do


Between #01/01/2016# And #02/1/2016#

to make sure you get the last day of January
I forget which way is correct
 
Upvote 0
you also might want to do


Between #01/01/2016# And #02/1/2016#

to make sure you get the last day of January
I forget which way is correct
No, you wouldn't want to do that.
Between is inclusive (think greater than or equal to, less than or equal to)

So if you did it that way, it would also pick up February 1.

The only thing to consider is if you have a time component to your dates, then you probably want to use something like:
Code:
>= #1/1/2016# and < #2/1/2016#
That will pick up everything from midnight 1/1/2016 up to 1/31/2016 11:59:59 PM.
Otherwise, you would miss anything that happened on 1/31/2016 after midnight.
(Leaving off the time component is a value of 0:00:00 AM, or Midnight).
 
Upvote 0

Forum statistics

Threads
1,221,713
Messages
6,161,463
Members
451,708
Latest member
PedroMoss2268

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