dd/mm/yyyy
-
hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!
-
hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!
Select datamonth from datemonthtest where datamonth BETWEEN strdatefrom AND strdateto
only two letters away from being an asset
-
hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!
charleslau2855 wrote:
anyone know how to search the date by "dd/mm/yyyy" in sql query!
select convert(varchar(10), getdate(),101)
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates
-
charleslau2855 wrote:
anyone know how to search the date by "dd/mm/yyyy" in sql query!
select convert(varchar(10), getdate(),101)
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates
albCode wrote:
charleslau2855 wrote: anyone know how to search the date by "dd/mm/yyyy" in sql query! select convert(varchar(10), getdate(),101)
That does not "search". It formats. The original question has a false lead in it by requesting a specific format. Date searches are format free because SQL Server does not store the date in a specific locale.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!
Use parameters then you don't need to worry about date formats and it reduces your worries about a SQL Injection attack. Also, if you are going to put a date into a SQL string it is better to use the ISO format which is
yyyy-mm-dd
becuase it is locale independent.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos