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

Problem comparing a DateTime field with a DateTime parameter !!

Status
Not open for further replies.

Ajith2002

Programmer
Jul 16, 2002
30
US

Hi Friends,

How do we compare a DateTime field with a DateTime value selected from a Parameter field ?
The field in the DB is of type String and is of the format - 2003-01-08 12:17:53.000
The DateTime parameter value is in the format - MM/DD/YYYY HH:MM:SS

How do we format these dates properly so that we can use it in the Record Selection formula ?

Any suggestions highly appreciated!!

-Ajith
 
If your sting is consistent in the format you have shown, (yyyy-MM-dd_hh:mm:ss) the following should work. I'm working "blind" (Crystal is a work, I'm not)
NOTE {yf}=your field

Create this formula to change 2003-01-08 12:17:53.000 to 01/08/2003 12:17:53pm

numbervar yr:=val({yf}[1 to 4]));
numbervar mnth:=val({yf}[6 to 7]);
numbervar dy:=val({yf}[9 to 10]);
numbervar hr:=val({yf}[12 to 13]);
numbervar min:=val({yf}[15 to 16]);
numbervar sec:=val({yf}[18 to 19]);

datetime(yr,mtn,dy,hr,min,sec) Mike
If you're not part of the solution, you're part of the precipitate.
 
Or a much easier formula if you always have ".000" ending your string

cdatetime(left({@string date},length({@string date})-4))

(I'm not sure what version the crdatetime function is first available) Mike
If you're not part of the solution, you're part of the precipitate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top