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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help comparing DateTime value

Status
Not open for further replies.

mgkSHA

Programmer
Jul 12, 2002
126
0
0
US
I am one step away from a Crystal Automation project being completed. This problem is driving me crazy, so I hope you guys can help me. I have a Date field and a formula that calculates time. I have combined these two fields into one formula that I use as a datetime stamp: the formula is called @DateCombine, and it has this simple formula:

*********************************************************

DateTimevar timeStamp;

timeStamp:=DateTime({TWDATA.LastChangeDate},{@convertNum})

***********************************************************

So in my report I have a date time field that reads like a date stamp 02/06/2003 3:53 PM.

Now in the automation script I am comparing this dateTime field with another date time stamp created in vbscript. The date time stap in vbscript is created by simply using the Now() command. So on my .log File I have:

02/06/2003 3:45 PM.

So in my recordselection formula I have tried EVERYTHING, nothing seems to work..this is what I currently have, I have tried other combinations of DateTime(Date(), DateTimeValue(Date(), etc....

Rept.recordselectionformula = "{@DateCombine} > Date(#" & strVal & "#)"


this always returns NO records for today..even though:

strVal = 02/06/2003 3:45 PM and "{@DateCombine}" = 02/06/2003 3:50 PM.

Basically, the initial date is being compared 02/06/2003 and nothing else. How do I do a full date comparision on a date time field? Please help. Thanks
 
If you're just using now(), use currentdatetime in Crystal syntax instead.

The key is to see what Crystal is getting passed by your app., so you might consider creating a datetime parameter in CR and just setting it from your app, that way you can display what's in the parm readily on the report.

-k
 
Thanks for your response. The problem is, I can't use now() when trying to set the recordselectionformula. After I run the procedure I WRITE OUT Now() to mark the last time this application ran. So the next time I run the Crystal Automation script I need to pass in this value. So the last time this script ran could be 02/06/2003 4:18 PM. Then in my recordselection formula I pass in this value to the dateTime formula. The problem is, I can't get the comparison right. How do I pass '02/06/2003 4:18 PM' to the dateTime formula? If I can pass this in, my problem is solved, then this statement would work, right now it is just comparing the date, not the whole dateTime string.

Formula (which is DateTime) > '02/06/2003 4:18 PM'

I am desperate at this poing, so any ideas would be appreciated.
 
Sorry, it finally dawned on me, use datetime, not date:

DateTime ("10/4/1999 10:20am")

-k
 
Actually, I was close all along, I was treating my strVal (the string from the .log file) as a number or Date using #'s around it. After I saw your post I modified the code to this:

Rept.recordselectionformula = "{@DateCombine} > DateTime('" & strVal & "')"

now it works...I forgot that I was BRINGING IN a string LOL..and I had to convert it via DateTime. Thanks I owe you one!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top