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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Search By Date

Author  Topic 

asif372
Posting Yak Master

100 Posts

Posted - 2011-03-07 : 23:41:16
i have a datetime column Like this
Date Shift
10/18/2010 2:39:08 PM (A)
10/24/2010 10:11:53 PM (A)
i want to update shift between these two values search by date how can we do this

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2011-03-08 : 00:18:54
quote:
Originally posted by asif372


i want to update shift between these two values search by date how can we do this



Can you provide more detailed information along with some sample data and expected output.
Go to Top of Page

asif372
Posting Yak Master

100 Posts

Posted - 2011-03-08 : 01:50:21
have a datetime column Like this
{ID}{Date} {Shift}
{1}10/16/2010 2:39:08 PM (A)
{1}10/117/2010 2:39:08 PM (A)
{1}10/18/2010 2:39:08 PM (A)
{1}10/19/2010 10:11:53 PM (A)
{1}10/20/2010 10:11:53 PM (A)
{1}10/21/2010 10:11:53 PM (A)
{1}10/22/2010 10:11:53 PM (A)
{1}10/23/2010 10:11:53 PM (A)
{1}10/24/2010 10:11:53 PM (A)
{1}10/25/2010 10:11:53 PM (A)
{1}10/26/2010 10:11:53 PM (A)
{1}10/27/2010 10:11:53 PM (A)
i want to update shift between 10/18/2010 and 10/24/2010 these two values search by date how can we do this

output shuld be like this

{1}10/18/2010 2:39:08 PM (R)
{1}10/19/2010 10:11:53 PM (R)
{1}10/20/2010 10:11:53 PM (R)
{1}10/21/2010 10:11:53 PM (R)
{1}10/22/2010 10:11:53 PM (R)
{1}10/23/2010 10:11:53 PM (R)
{1}10/24/2010 10:11:53 PM (R)

any idea???
thanks in advance
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-08 : 02:18:36
[code]
update t
set shift = 'R'
from yourtable t
where Date >= '2010-10-18'
and Date < '2010-10-25'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-10 : 10:31:08
Also make sure to use unambigious date format
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -