DateFormat,Date,SQL

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
125
Office Version
  1. 2016
Platform
  1. Windows
Hi All,
I would like to run the following query using date range
Start Date = 01/10/2010 dd/mm/yyyy
End DAte = 31/03/2011 & 23:59:59 dd/mm/yyyy

When I run the Option-1 one using "Parameters" its run ok

Option-1
WHERE (((AdmitDate)<=DateAdd("d",1,[End Date]))
AND ((DischDate)>=DateAdd("d",-28,[Start Date]))

Option-2 (Problem)
When I run the follwoing query it doesn't bring more rows which I'm expecting

AND ((DischDate)>= DateAdd("d",-28,format("01/10/2010","dd/mm/yyyy"))
And (AdmitDate)<=DateAdd("d",1,Format("31/03/2011","dd/mm/yyyy") & " 23:59:59")

I think its the format problem even I tried using # using American format still the same problem mm/dd/yyy. My System|ControPanel|Regional setting is UK i.e dd/mm/yyyy

Thanks for you help
Regards
F
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Why are you using the Format function for the dates in the second example?

Apart from that you should have a look at the Between operator if the criteria is a date range.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

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