Urgent: Date function help required for Access query

Get help on programming - C++, Java, Delphi, etc.
Post Reply
User avatar
Tribble
Registered User
Posts: 88465
Joined: 08 Feb 2007, 02:00
Processor: Intel Core i7-4770K CPU@3.50GHz
Motherboard: ACPI x64-based PC
Graphics card: GeForce GTX 780 Ti
Memory: 16GB
Location: Not here
Contact:

Urgent: Date function help required for Access query

Post by Tribble »

Please forgive me for interrupting you all on a Sunday night.

This is an easy question but my brain is no longer functioning.

Using an Access select query. In a date field I need to specify that only data of the current week must show (Monday to Friday). How do I do this - I am going mad trying to figure it out. As I say I know it is simple - just cannot think anymore. Will search the other forums in case there is no one here who can help.


A slightly harder question - how do I use the between [date] and [date] function in a crosstab query?

Thanks for any suggestions you can make.
Image
Hex_Rated
Registered User
Posts: 3679
Joined: 19 Jan 2006, 02:00
Contact:

Post by Hex_Rated »

Have a look at the datepart function:

WHERE datepart(wk,your_date_field_name) = datepart(wk,now()) -- makes records match current week number
AND datepart (dw, your_date_field_name) > 1 -- monday to
AND datepart (dw, your_date_field_name) <7 -- friday


Sorry, I have no idea if it will work.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
User avatar
Tribble
Registered User
Posts: 88465
Joined: 08 Feb 2007, 02:00
Processor: Intel Core i7-4770K CPU@3.50GHz
Motherboard: ACPI x64-based PC
Graphics card: GeForce GTX 780 Ti
Memory: 16GB
Location: Not here
Contact:

Post by Tribble »

Thanks I will try that. I appreciate the answer. Will let you know.
Image
User avatar
Tribble
Registered User
Posts: 88465
Joined: 08 Feb 2007, 02:00
Processor: Intel Core i7-4770K CPU@3.50GHz
Motherboard: ACPI x64-based PC
Graphics card: GeForce GTX 780 Ti
Memory: 16GB
Location: Not here
Contact:

Post by Tribble »

Solution (thanks to my friend Albert)

Create a column in the query with this as the field data

Code: Select all

Week: Format([CaptureDate],"ww")
And this as the criteria

Code: Select all

Format(Date(),"ww")

Thanks Hek Rated - never got to try your solution. Will do sometime and will let you know.
Image
Post Reply