Showing posts with label way to extract Date from field which contains Timestamp. Show all posts
Showing posts with label way to extract Date from field which contains Timestamp. Show all posts

Monday, February 11, 2013

Extract date from timestamp in crystal report 2008



 Using Crystal Report 2008 :

Found a way to extract Date from field which contains Timestamp.

for ex: userevent table there is a table.field which contains timestamp. And i want to convert into a date
while eliminating time .

you can see here;

for example timestamp field contains 20130128145651 this date and time . now i wanted to convert into
01/28/2013 format.

you can try using this formula:


Go to formula -> create a new formula -> type in the below formula

date(tonumber("20" & mid({table.field},3,2)),tonumber(mid({table.field},5,2)),tonumber(mid({table.field},7,2)))

check for errors by clicking x+2 -> save and close.

place the formula in the details section and  preview.


or you check this formula too..


//stringvar dt;
//
//dt:=(totext(Year(currentdate),'0000')&totext(Month(currentdate),"00")&totext(day(currentdate),'00'));
//
//tonumber(dt);


First one worked for me in this case and second one is also similar