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

Have Problems matching up date fields

Status
Not open for further replies.

RachelK

Programmer
Mar 18, 2002
171
GB
I have a date field that is coming up like 7/12/01 or 11/1/02, I have formatted this date now to ddmmyyyy I have another field with the year in. I would like to create a new formula to say if the years = the same then show it else 0, but as It's a date field I can't use 0

Right (ToText ({@PEPREV.DATE_APPLIED}),4 ) = {@Year} Then {@PEPREV.DATE_APPLIED} Else no date
 
This is awkward I agree....I usually convert all my date outputs to text strings and that eliminates what to use for null dates...the other alternative is to suppress the field when a "zero" date (eg 1900/01/01 if you decide that is zero date) is generated

also I would do the comparison a bit differently...I assume that {@Year} is a string.

if ToText(year({@PEPREV.DATE_APPLIED}),0) = {@Year} Then
totext({@PEPREV.DATE_APPLIED},"ddMMyyyy")
Else
"";

NOTE: MM in ddMMyyyy is used for Month...mm is minutes

Hope this helps

Jim
JimBroadbent@Hotmail.com


 
Thanks for you help, I don't understand what this part of the formula is doing ?
(year({@PEPREV.DATE_APPLIED}),0)
 
sorry .... I assumed that @PEPREV.DATE_APPLIED was a date...is it a number??

if the sole purpose of @PEPREV.DATE_APPLIED is to convert a date to a number for this comparison formula then you can eliminate @PEPREV.DATE_APPLIED and use the date directly

if ToText(year({Table.date}),0) = {@Year} Then
totext({Table.date},"ddMMyyyy")
Else
"";

ToText(year({Table.date}),0) takes the "year" portion of a date value and converts it to text...with no decimals

If you need @PEPREV.DATE_APPLIED as a number for other purposes in the report then the formula should be

if ToText(right({@PEPREV.DATE_APPLIED}),4) = {@Year} Then
totext({@PEPREV.DATE_APPLIED},0)
Else
"";

Jim
JimBroadbent@Hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top