Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Villanuev
Constraint Violating Yak Guru
478 Posts |
Posted - 2012-01-31 : 02:37:11
|
| Hi ExpertI have a field with datetime datatype.i just want to validate and pullout data using the date and time.something like this.. from '2012-01-29' and 12:00AM to '2012-01-30' and 12:00AM Sample tableCreate Table #TABLE1(ASURAFDATETIME datetime)Insert into #TABLE1 values ('2012-01-30 00:54:05.000')Insert into #TABLE1 values ('2012-01-30 11:52:48.000')Insert into #TABLE1 values ('2012-01-30 00:55:15.000')Insert into #TABLE1 values ('2012-01-29 19:30:54.000')Insert into #TABLE1 values ('2012-01-30 00:55:38.000')Insert into #TABLE1 values ('2012-01-30 04:39:50.000')Select * #Table1where ASURAFDATETIME >='2012-01-29' and ASURAFDATETIME < '2012-01-31'and ???[code][\code]Thanks,JOV |
|
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2012-01-31 : 04:12:22
|
| select * from #TABLE1 where ASURAFDATETIME > CONVERT(datetime, '2012-01-29') AND ASURAFDATETIME < CONVERT(datetime, '2012-01-29')If you want to add time then select * from #TABLE1 where ASURAFDATETIME > CONVERT(datetime, '2012-01-29 12:35AM') AND ASURAFDATETIME < CONVERT(datetime, '2012-01-29 12:35AM')SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
 |
|
|
Villanuev
Constraint Violating Yak Guru
478 Posts |
Posted - 2012-01-31 : 04:28:17
|
| Thank you very much.. |
 |
|
|
|
|
|