[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Year To Date???



Thanks Much
Dave Benzenhafer

-----Original Message-----
From: Rick_Creel@AONCONS.COM [mailto:Rick_Creel@AONCONS.COM]
Sent: Tuesday, August 08, 2000 10:22 AM
To: SQR-USERS@list.iex.net
Subject: Re: Year To Date???


In order to use date VARIABLES they must be explicitly delcared as a DATE
variable.  If you don't declare them as a DATE variable, SQR assumes that
the $
name is a character type variable.

As for hard-coding the date.... you shouldn't have to hard code anything.
Using
 the various date & string fucntions
available to SQR, you should be able to write code that would take the date
you
are wanting to compare against
and get the YEAR portion from it, then concatenate that with 01-01 and then
convert that back to a date variable.

I tested this code, and it works (Oracle environment):

begin-setup
   declare-variable
      date    $run_date $first_of_year
      integer #number_of_days
   end-declare
end-setup

begin-report
begin-SELECT
sysdate &current_date
from    dual
end-SELECT

move &current_date to $run_date
let $current_year = datetostr($run_date,'yyyy')
let $Jan_01 = '01-01-' || $current_year
let $first_of_year = strtodate($Jan_01,'mm-dd-yyyy')
let #number_of_days = datediff($run_date,$first_of_year,'day')
show 'Current run date  ' $run_date
show 'First of year     ' $first_of_year
show 'Elapsed days      ' #number_of_days
end-report

------------------------------------------------------------
The results:
Current run date  08-AUG-2000
First of year     01-JAN-2000
Elapsed days      220





"Benzenhafer, Dave" <DBenzenhafer@DEEPWATER.COM> on 08/08/2000 10:41:50 AM

Please respond to sqr-users@list.iex.net

To:   SQR-USERS@list.iex.net
cc:    (bcc: Rick Creel/IT/Aon Consulting)

Subject:  Re: Year To Date???



What I'm looking for is The first of the year not to be a hard coded date so
that the report can be used year after year. The problem that I had with
datediff was that it needed actual dates. I didn't seem to work with a
variable in place of a date

-----Original Message-----
From: Rick_Creel@AONCONS.COM [mailto:Rick_Creel@AONCONS.COM]
Sent: Tuesday, August 08, 2000 9:05 AM
To: SQR-USERS@list.iex.net
Subject: Re: Year To Date???


I am not sure about the summarize function you are seeking.
You can use the DATEDIFF function to determine the number of days.
For example, If you have 2 date variables:

$first_of_year   is set to 01-01-2000
$current_date is set to the date you are working with, like 08-08-2000
then #number_of_days = datediff($current_date,$first_of_year,'day')

Hope this helps





"Benzenhafer, Dave" <DBenzenhafer@DEEPWATER.COM> on 08/08/2000 09:34:44 AM

Please respond to sqr-users@list.iex.net

To:   SQR-USERS@list.iex.net
cc:    (bcc: Rick Creel/IT/Aon Consulting)

Subject:  Year To Date???



Is there a SQR function that will let summarize a cost field Year To Date or
Month To Date. I am also looking for a way to count the days from the first
of a year to a date in that year.

Any help will be appreciated

Dave Benzenhafer
Transocean Sedco Forex
dbenzenhafer@deepwater.com