Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Showing Date ONLY in a formula field Post Reply Post New Topic
Author Message
gitanjali1027
Newbie
Newbie
Avatar

Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
Quote gitanjali1027 Replybullet Topic: Showing Date ONLY in a formula field
     Posted: 02 Aug 2010 at 11:03am
How do i get a result like:  1974 where it is the YEAR only when i have this formula field:

toText({DataTable1.Name})



IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 02 Aug 2010 at 7:27pm
and what type of {DataTable1.Name} do you have?
can you give us some sample data for this field?
 
 
hope can help.
 
 
Emir W
IP IP Logged
gitanjali1027
Newbie
Newbie
Avatar

Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
Quote gitanjali1027 Replybullet Posted: 03 Aug 2010 at 3:42am
the Field is a Date/Time .  On my report i'd like it to ONLY output years formatted as: 1974, 1998, 1990, etc.  Right now it's displaying as 1/1/1970
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Aug 2010 at 3:54am
a few ways to do this
right click on the datetime field
format field
date and time tab
select customize
on Date and Time tab select order as Date
on date tab make
month as none
day as none
year as '1999'
 
or make a formula field as
year(table.datefield) then change the way the number looks using the a similar priocess to above
 
or make a fomrula field to convert it to text
totext(year(table.datefield),0,'')
 
IP IP Logged
gitanjali1027
Newbie
Newbie
Avatar

Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
Quote gitanjali1027 Replybullet Posted: 03 Aug 2010 at 4:10am
this didn't seem to work -- my results looked like 1,1970?  I put this into my formula:

toText(year({DataTable1.Name}))

i tried to put in this:  toText(year({DataTable1.Name}), 0,") but kept hitting errors "The matching " for this string is missing". 


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Aug 2010 at 4:24am

the end is 2 single quotes but you can use 2 double quotes if you want

ToText(year({DataTable1.Name}), 0,"")



Edited by DBlank - 03 Aug 2010 at 5:01am
IP IP Logged
gitanjali1027
Newbie
Newbie
Avatar

Joined: 01 Apr 2010
Online Status: Offline
Posts: 25
Quote gitanjali1027 Replybullet Posted: 03 Aug 2010 at 5:00am
ah, excellent!  it works great!  thank you!!!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum