Print Page | Close Window

Day of the Week formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6640
Printed Date: 01 May 2024 at 6:47pm


Topic: Day of the Week formula
Posted By: Kathleen
Subject: Day of the Week formula
Date Posted: 09 Jun 2009 at 12:00pm

I am trying to use the day of the week function to get a date to be represented as only the day of the week it occurred on.

Meaning, {mederror.errordate} equals 06/09/09
I would like the formula to print "TUESDAY"
 
I cannot make this work, I'm not sure if our dates aren't set up as "dates" or what, can someone help me out with this?
 
Thanks in advance



Replies:
Posted By: DBlank
Date Posted: 09 Jun 2009 at 2:29pm
WeekdayName(Weekday({mederror.errordate}))
or if that is not a date field try
WeekdayName(Weekday(cdate({mederror.errordate})))


Posted By: Kathleen
Date Posted: 10 Jun 2009 at 9:09am
I have now tried WEEKDAYNAME(Weekday({mederror.errordate}))) and received the error stating that a date must be here (where the {} field is.
 
I have also tried WEEKDAYNAME(Weekday(cdate({mederror.errordate}))) and I receive bad format or string name.
 
Are there any other suggestions?
 
I guess this may take using two different formulas - first putting the date into a proper date format (I don't know how to do that) and then moving that new created field into one of the formulas above??
 
Does that sound doable?


Posted By: DBlank
Date Posted: 10 Jun 2009 at 9:42am

couple of questions to tease this out.

1. In your field explorer, what data type is listed next to the mederror.errordate field?
2. Can you post some sample data that is actually from the field ... especially if there is ever instances that use an alpha character.


Posted By: rahulwalawalkar
Date Posted: 15 Jun 2009 at 7:10am
Hi
 
You can try this in your formula to test what records don't have the date format which is expected by cdate function....
 
If IsDate({mederror.errordate}) Then
WEEKDAYNAME(Weekday(cdate({mederror.errordate})))
else
currentdate
 
cdate is bit picky in the format it accepts the date...
 
cheers
Rahul
 
P.S. Different checks you can include in the formula.....
 
IF IsNull({mederror.errordate}) or Trim({mederror.errordate}) = ""
 
totext({mederror.errordate},'dd/MM/yyyy')
 



Print Page | Close Window