Focal Point
how to substract 24 hr from system day

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6871016372

February 27, 2008, 09:55 AM
vkrugman
how to substract 24 hr from system day
Hello,

I need to get records for last 24 hours.
I think I need to add time stamp to my parameter value(&NSDAT) and substract 1 day (to be exact 24 hr). Not sure how to do this.In my query I need to filter on ZZSHIP_DATE field which is A8 Please help.
Here are my parameter:
-DEFAULT &SDAT='&YYMD.EVAL', &EDAT='&YYMD.EVAL';
-SET &NSDAT=AYMD(&EDAT,-1,'I8'); (returned value is 20080227)

Thanks


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
February 27, 2008, 10:43 AM
Prarie
Here is an example of subtracting a day from a date stamp. Do some research on HADD for more help.

WDATE1/HYYMDI = HADD(WKEND_DATE,'DAY',-1,8,WDATE1);


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Lera,
do you just need to know how to get the current system time?
&TOD will give you time, in addition to &YYMD which you're already using for the date.
These two together can be input to various Date-Time functions, such as HINPUT for converting an alpha string into a date-time value, then performing your addition/subtraction as Prarie has suggested. See the Using Functions manual beginning page 185.
Is that what you needed to know?

..
TOD stands for TimeOfDay, but you figured that out, I'm sure.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Interesting that this post came up since I just had to use this yesterday for the first time in a long while. You've already been given an example for subtracting the day. Now you need to compare a date-time to an alpha field.
You can redefine the alpha date to a date-time value or you can convert the dat-time variable to an alpha. by far the most efficient thing to do would be to convert your &variable to the format of your real field (the alpha data ZZSHIP_DATE). Comparison against a defined field is highly inefficient.

Here's my suggestion - Forget about the time stamp and hour stuff. Get today's date and just subtract one day:

-SET &NSDATE = DATEADD(&YYMD, 'D', -1);

This gives you a value of 20080226. You can then use this directly in your WHERE clause:

WHERE ZZSHIP_DATE GE '&NSDAT.EVAL'


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
Yes, I've done that already! But I need to make sure I'm not loosing records starting at 16:00 yesterday. My program will be executed @ 4:00pm(16:00) every day, and I need all data for alst 24 hr(everything from yesterday 4:00 pm)

if I just use - 'D', -1 what is the start poind of yesterday?


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
quote:
Originally posted by susannah:
Lera,
do you just need to know how to get the current system time?
&TOD will give you time, in addition to &YYMD which you're already using for the date.
These two together can be input to various Date-Time functions, such as HINPUT for converting an alpha string into a date-time value, then performing your addition/subtraction as Prarie has suggested. See the Using Functions manual beginning page 185.
Is that what you needed to know?

..
TOD stands for TimeOfDay, but you figured that out, I'm sure.


I need to make sure I'm getting records starting at 16:00 yesterday. My program will be executed @ 4:00pm(16:00) every day, and I need all data for last 24 hr(everything from yesterday 4:00 pm) So I need to substract somehow 24 hours from current day and time(hours and minutes only)


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
Your field for filtering is only an Alpha 8 so there is nothing to compare to except the day - regardless of when you run the report. If you were to time-date stamp the ship field instead of only date stamp, you could do some additional processing.

The start point of the day is always 12:00AM - the day begins at midnight. So anything that happened during the ENTIRE previous day would pass your filter.

You can subtract 24 hours from right now (Today @ 4PM), but you've got nothing to compare that value against. If you ONLY want to get records starting from 4PM yesterday, you're going to have to include some sort of time stamp on the record itself - a simple A8 field won't do it. I don't think there's a way around that one.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
TOD is important to you, so just subtracting 1 day won't do.
Do you have a timestamp in the database , along with the Date field/A8?? I've seen db's in which the two are kept in separate fields.
You should have what you need now, using &TOD along with &YYMD, and have you downloaded the Using Functions manual?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
Yes,subtracting 1 day won't work. I have two fields in a table that I think I need to filter on: ZZSHIP_DATE (A8) and ERZET(A6)- TIME.
So,I'm not sure how to use all those date/time functions but I need from current date and time substract 24 hr. If you know syntex, please give me a sample.


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
You can keep the date and time separate, subtract 1 from the day and then use BOTH fields to do the comparison against current date and &TOD.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
Lera, just download that Using Functions manual and look at the chapter on Dates. the examples are very good and quite clear.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
THANK YOU.


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
There you go - you can compare ZZSHIP_DATE to your variable calculated from &YYMD and compare ERZET to your calculation from &TOD.

Default format for &TOD is HH.MM.SS so you'll probably have to edit out the periods to be able to compare against an A6 time field.

The Using Funtions manual (especially the Date and Time section) is the most used manual on my shelf. Good luck


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
THANK YOU, DARIN


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
Lera

if the basic manual is not giving you the proper answers I can recommend the book

"Almost 1001 Ways to work with DATES in WebFOCUS"
You can order it at Information Builders, (or via Bol.com)




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

if I am not mistaken &tod will be the time you enetred the session and not the current time.. for current time would it not be better to use HHMMSS?

IN A DEFINE...
TIME/A8=HHMMSS(TIME,'A8');

IRA
wf 538 aix 533


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
thank you


Valeriya

WebFOCUS 764 Servlet - MRE/Dashboard/Self Service/ReportCaster - Windows 2000
&TOD is the system time at the moment you execute the request on the server.

You're going to get the same value regardless of which you use. HHMMSS is a function so you have to remember parameters. &TOD is easier and you don't have to remember parameters.
Anything I don't have to remember is easier for me! Smiler


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat