Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: converting string to date Post Reply Post New Topic
Page  of 3 Next >>
Author Message
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Topic: converting string to date
    Posted: 14 Sep 2010 at 4:30am
Hi All,
 
I think the problem which iam posting is simple..but unable to figure out..
I have column which is string[300] ineed to convert it to date.how can i write a formula for that..and moreover at runtime when the user enters the date..he wanted to enter only the startdate and if he doesn't enter the enddate it should take it as sysdate.
 
Any help would be appreciated...
 
Thanks
Swapna
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Sep 2010 at 4:57am
1. What does the date string look like?
2. How are your prams set up for an end date and do you have crystal 2008?
IP IP Logged
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Posted: 14 Sep 2010 at 5:08am

Hi..

My date string is in this format '08/25/2010 08:51:30'

and yes iam using crystal 2008..i have created two parameters and took and took the type as date and created a formula for both the parameters
 
IF HasValue({?StartDate})
THEN {?StartDate}
ELSE CurrentDate
 
 
and in the same way for endate also..when i select expert
 
not hasvalue({?startdate})OR {{Command.TRANSDT} >= {@ffStartDate}) and
(not hasvalue({?endDate}) OR {Command.TRANSDT} <= {@ffEndDate})
 
it throws me error that string is required here..as the transdt column is sting type.
 
Thanks
Swathi
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Sep 2010 at 5:18am
not very familiar with the new 2008 hasvalue() as I am still on vXI but I think this is what you want.
(hasvalue({?endDate}) and date({Command.TRANSDT}) in {?startdate} to {?enddate})
or
(NOT (hasvalue({?endDate})) and date({Command.TRANSDT}) in {?startdate} to currentdate)
 
 
date({Command.TRANSDT}) can be used to convert your string
IP IP Logged
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Posted: 14 Sep 2010 at 5:52am
Hi..I tried both of them..but it doesn't work..can you suggest me what should i do..
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Sep 2010 at 6:02am

This goes in the select expert:

 
(hasvalue({?endDate}) and date({Command.TRANSDT}) in {?startdate} to {?enddate})
or
((NOT (hasvalue({?endDate})) and date({Command.TRANSDT}) in {?startdate} to currentdate)
 
When you say iot does not work what error are you getting?
IP IP Logged
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Posted: 14 Sep 2010 at 6:21am
It says that "a date range is required here"
IP IP Logged
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Posted: 14 Sep 2010 at 6:26am
The problem is that i don't to enter the enddate..it optional..if nothing is given..i t should take as sysdate automatically..but it is forcing me to enter enddate..
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Sep 2010 at 6:29am
Do you have the enddate set to allow for NULLs in its properties?
IP IP Logged
swapna123
Newbie
Newbie


Joined: 14 Sep 2010
Online Status: Offline
Posts: 15
Quote swapna123 Replybullet Posted: 14 Sep 2010 at 6:34am
I dont find anything to set it to null in properties..do u mean to say in parameters?
IP IP Logged
Page  of 3 Next >>
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.