|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stored Proc - Return Records with Current Date
I want to write a stored procedure that will return the records with the current date.
I have tried Select * from tbl where Datefield = GetDate() But this yields no results presumably because the dates in the date field are mm/dd/year, whereas GetDate returns date and time if I remember correctly. I've tried Date() but that produces an error. Any suggestions? Thanks a mil. |
|
#2
|
||||
|
||||
|
This might help you out: http://www.databasejournal.com/feat...cle.php/1442021
|
|
#3
|
|||
|
|||
|
Use convert() function
look up convert() function for detail.
|
|
#4
|
|||
|
|||
|
Thanks all. This is very helpful and interesting ...
|
|
#5
|
|||
|
|||
|
I have a similar but not identical question. I am creating a printable calendar. I want the user to be able to select the dates and then pass those to a query, so that it will return all events between the two dates. Here is what I have:
SELECT * FROM tbl_Calendar WHERE fromdate Between Convert(Datetime, 11/5/2003, 1) and Convert(Datetime, 12/31/2003, 1) ORDER BY FromDate ASC While it's not giving an error, it is not returning any values. Can anyone spot the problem? |
|
#6
|
|||
|
|||
|
Got it! I was looking for events that were occuring between two dates, not starting on the start date and ending on the end date!
too easy! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Stored Proc - Return Records with Current Date |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|