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 > help with date function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-08, 07:17
Colin4 Colin4 is offline
Registered User
 
Join Date: Jul 2006
Posts: 8
help with date function

Can anyone tell me how to caluculate a certain day of the prior month using getdate() ? The function will be hardcoded in a query that will run on either of the 1st 7 days of the month - Specifically the the 1st through the 7th day of the following month.

ie: If it runs on April 3, I need the getdate() function to retrieve March 15th,
if it runs on May 6, I need the getdate() function to retrieve April 15th.
Thanks in advance for any help.
Reply With Quote
  #2 (permalink)  
Old 04-22-08, 02:56
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
select dateadd(dd,14,dateadd(mm,datediff(mm,'20000101',ge tdate())-1,'20000101')) '15thPrevMth'
Reply With Quote
  #3 (permalink)  
Old 04-24-08, 10:09
Colin4 Colin4 is offline
Registered User
 
Join Date: Jul 2006
Posts: 8
That worked, thanks.
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