|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Selecting dates in SQL ServerI have a table with a date field and one of the
rows has a date value of '2009-03-31 16:39:16.000'. I'm trying to use a SELECT statement like this: SELECT * FROM MyTable WHERE fldDate >= '01/01/09' AND fldDate <= '03/31/09' The results will not include the above stated record. Is there some way to change the SQL statement that will include it? Kevinp wrote:
> I have a table with a date field and one of the '03/31/09' is equal to '03/31/09 00:00'> rows has a date value of '2009-03-31 > 16:39:16.000'. > > I'm trying to use a SELECT statement like this: > SELECT * FROM MyTable WHERE fldDate >= '01/01/09' > AND fldDate <= '03/31/09' > > The results will not include the above stated > record. Is there some way to change the SQL > statement that will include it? '2009-03-31 16:39:16.000' is not before and not equal to 03/31/09 00:00 If you want to include the 31th of March 2009, use < '04/01/2009' (which is also true if you use SQLParameters) Armin On Fri, 29 May 2009 01:31:56 +0200, "Armin
Zingler" <az.nospam@freenet.de> wrote: Show quoteHide quote >Kevinp wrote: Yes, I realize that. Entering '04/01/09' is not>> I have a table with a date field and one of the >> rows has a date value of '2009-03-31 >> 16:39:16.000'. >> >> I'm trying to use a SELECT statement like this: >> SELECT * FROM MyTable WHERE fldDate >= '01/01/09' >> AND fldDate <= '03/31/09' >> >> The results will not include the above stated >> record. Is there some way to change the SQL >> statement that will include it? > >'03/31/09' is equal to '03/31/09 00:00' > >'2009-03-31 16:39:16.000' is not before and not equal to 03/31/09 00:00 > >If you want to include the 31th of March 2009, use > > < '04/01/2009' > >(which is also true if you use SQLParameters) > > >Armin acceptable to my users who only want up to '03/31/09'. Kevinp wrote:
Show quoteHide quote > On Fri, 29 May 2009 01:31:56 +0200, "Armin Add one day by code.> Zingler" <az.nospam@freenet.de> wrote: > >> Kevinp wrote: >>> I have a table with a date field and one of the >>> rows has a date value of '2009-03-31 >>> 16:39:16.000'. >>> >>> I'm trying to use a SELECT statement like this: >>> SELECT * FROM MyTable WHERE fldDate >= '01/01/09' >>> AND fldDate <= '03/31/09' >>> >>> The results will not include the above stated >>> record. Is there some way to change the SQL >>> statement that will include it? >> >> '03/31/09' is equal to '03/31/09 00:00' >> >> '2009-03-31 16:39:16.000' is not before and not equal to 03/31/09 >> 00:00 >> >> If you want to include the 31th of March 2009, use >> >> < '04/01/2009' >> >> (which is also true if you use SQLParameters) >> >> >> Armin > > Yes, I realize that. Entering '04/01/09' is not > acceptable to my users who only want up to > '03/31/09'. Armin On Fri, 29 May 2009 04:56:16 +0200, "Armin
Zingler" <az.nospam@freenet.de> wrote: Show quoteHide quote >Kevinp wrote: Thanks for the suggestion, but I 'fixed' it. I was>> On Fri, 29 May 2009 01:31:56 +0200, "Armin >> Zingler" <az.nospam@freenet.de> wrote: >> >>> Kevinp wrote: >>>> I have a table with a date field and one of the >>>> rows has a date value of '2009-03-31 >>>> 16:39:16.000'. >>>> >>>> I'm trying to use a SELECT statement like this: >>>> SELECT * FROM MyTable WHERE fldDate >= '01/01/09' >>>> AND fldDate <= '03/31/09' >>>> >>>> The results will not include the above stated >>>> record. Is there some way to change the SQL >>>> statement that will include it? >>> >>> '03/31/09' is equal to '03/31/09 00:00' >>> >>> '2009-03-31 16:39:16.000' is not before and not equal to 03/31/09 >>> 00:00 >>> >>> If you want to include the 31th of March 2009, use >>> >>> < '04/01/2009' >>> >>> (which is also true if you use SQLParameters) >>> >>> >>> Armin >> >> Yes, I realize that. Entering '04/01/09' is not >> acceptable to my users who only want up to >> '03/31/09'. > > >Add one day by code. > > >Armin getting the date from a DateTimePicker control and only saving the date. Of course it adds the current time to the date. I changed my program so it wouldn't. Then I wrote a little loop to fix all the current records. I'm too anal to add a day by code :)
getting error on record duplication
Visual Studio 2008 hogging memory partition numbers in four terms ListView - Caching Thumbnails? automating ie or webbrowser control Define irregularly shaped area in UserControl where controls may be dropped Converting from Access exporting dataset to Excel is slow 32bit 64bit windows mobile pocketoutlook |
|||||||||||||||||||||||