Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Time in String and need in Date format

Status
Not open for further replies.

brazilhills

IS-IT--Management
Sep 12, 2003
41
US
I want to be able to set my Crystal Report to run daily report from Business Objects Server. In order to do this I want to set the "datetime" field to be in the period of CurrentDate - 1.
The date in the database is char(12) in this format YYYYMMDDhhmm. If I use the function below to convert the char(12) to DateTimeValue then my report is EXTREMELY inefficient.
How can I set my report to run for yesterday's date every time without having to do this conversion which taxes the database?
Here is what I'm using which is inefficient:
numbervar years:= ToNumber(mid({hst.exitdate},1,4));
numbervar months:=ToNumber(mid({hst.exitdate},5,2));
numbervar days:=ToNumber(mid({hst.exitdate},7,2));
numbervar hours:=ToNumber(mid({hst.exitdate},9,2));
numbervar mins:=ToNumber(mid({hst.exitdate},11,2));
numbervar secs:=00;
DateTimeValue(years,months,days,hours,mins,secs)
 
You might try converting the currentdate-1 instead of the datetime string:

{hst.exitdate} >= totext(currentdatetime-1,"yyyyMMddHHmm")

Since the conversion only has to happen once, it should save time. It would be even faster if you could do the conversion in a SQL expression.

-LB

 
Oh thank you. I was thinking about it backwards. I appreciate your help this did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top