Results 1 to 8 of 8

Thread: Function to get 2 dates

Hybrid View

  1. #1
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Function to get 2 dates

    by using a case statement and the datediff function...

    Code:
    case 
      when getdate() < convert(datetime, convert(varchar(4), year(getdate()) + '-09-01') then  convert(datetime, convert(varchar(4), (year(getdate())-1) + '-09-01') 
      else convert(datetime, convert(varchar(4), year(getdate()) + '-09-01') 
    end as startDate
    for the end date, it's similar logic... just change the 90-01 to 08-30 (I think you meant the end of august, not the end of September, otherwise you end up with an overlap.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  2. #2

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Function to get 2 dates

    I take it I can wrap this up in a function.
    I'm not in work at the moment but I'll mess around with this tomorrow but 'm stil not sure why I need CASE.
    Thanks for that.

    Parksie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width