Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Date string to Crystal 8 3

Status
Not open for further replies.

jmr9999

MIS
Sep 19, 2002
18
I am having difficulty manipulating a date string pulling off a SQL database. The format is YYYY/MM/DD HH:MM:SS.SS. Crystal is seeing it as a string, not DATETIME, I guess because of the SS.SS. Is there a way I could truncate the DATETIME coming from SQL into my CR report?
 
Try making a new formula

Date(mid(sqldate, 1,4),mid(sqldate,6,2),mid(sqldate,9,2))

Where sqldate is the date you pull from your sql database
 
I am getting a "Too many arguments have been given to this function" when I try it. Any suggestions?
 
I forgot to mention, when I run a ISDATETIME function against the datetime field, I get a "FALSE."
 
jmr9999:

I was having the exact same issue, actually posted my question right after yours. This is what I figured out and it worked for my conversion:

DateTime(
ToNumber( Mid( {Your_Date_Field}, 1,4) ),
ToNumber( Mid( {Your_Date_Field}, 6,2) ),
ToNumber( Mid( {Your_Date_Field}, 9,2) ),
ToNumber( Mid( {Your_Date_Field}, 12,2) ),
ToNumber( Mid( {Your_Date_Field}, 15,2) ),
0 );

Hope it helps!
 
You can also try this:
cdatetime(left({table.dateField}, instr("2000/01/01 11:39:15.15", ".") - 1))
 
Sorry...It's been a long day.

cdatetime(left({table.dateField}, instr({table.dateField}, ".") - 1))
 
synapsevampire is absolutely right - that's the simpiest one. ...and if you need to display time:

dtstodatetime("2002/12/31 12:34:43.32")
 
Thanks for all the help...I tried it a couple of different ways, and it works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top