×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Field Population based on Date Created

 Forum Search FAQs Links MVPs

## Field Population based on Date Created

(OP)
Hi

I have a need to populate a field in a Crystal Report (using SAP Crystal Reports 13)

The Population of the field will depend on the following Criteria

If the Day of running the report is a Monday and the {Create_Date} is in the last 72 hours then tag the field as NEW
If the Day of running the report is any other day and the {Create_Date} is in the last 24 hours then tag the field as NEW
Any records whose {Create_Date} falls outside the above then tag the field as EXISTING

I have used this formula before to look back different times based on the Day of the week, but im a little lost what needs to be done to achieve the above

(
if dayofweek(currentdate) = 2 then
{BMCServiceDesk__Problem__c.BMCServiceDesk__Closed_Date_Time__c} in dateadd("h",-72, datetime(currentdate,time(11,0,0))) to datetime(currentdate,time(13,0,0))
else
{BMCServiceDesk__Problem__c.BMCServiceDesk__Closed_Date_Time__c} in dateadd("h",-24, datetime(currentdate,time(11,0,0))) to datetime(currentdate,time(13,0,0))
)

Very grateful if anyone can nudge me in the right direction

Thanks

### RE: Field Population based on Date Created

I would have used the datediff function. I am not sure if the {BMCServiceDesk__Problem__c.BMCServiceDesk__Closed_Date_Time__c} is the {Create_Date} or that is another field.

if dayofweek(currentdate) = 2 then
if datediff('h',{Create_Date}, currentdate) <= 72 then 'NEW'
else 'EXISTING'
else
if datediff('h',{Create_Date}, currentdate <= 24 then 'NEW"
else 'EXISTING'

### RE: Field Population based on Date Created

(OP)
Thanks. Thats Perfect. Cheers

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!