If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Query for getting records within 2 date values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-18-11, 02:22
irudayaraj irudayaraj is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
Query for getting records within 2 date values

i have getdata() = 'Aug 17 2010'
i need to take getdate() - 5 value into another variable

@var1 = 'Aug 17 2010'
@var2 = 'Aug 12 2010'


the source table has this data

Name Busdt
aet 8/13/2010
adp 8/14/2010
add 8/10/2010
gdd 8/11/2010
hig 8/15/2010


now, i need to retrieve all the records with busdt falling between var1 and var2

how do i do this?

Thanks in advance

Last edited by irudayaraj; 08-18-11 at 02:30.
Reply With Quote
  #2 (permalink)  
Old 08-31-11, 17:41
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Depending if you want the time portion
dateadd(dd,-5,getdate())
or
dateadd(dd,datediff(dd,'',getdate())-5,'')
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On