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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting DateTimeValue with Milliseconds ??

Status
Not open for further replies.

WiZoRioT

IS-IT--Management
May 30, 2008
5
US
Please Help,

Im connecting to a SQL Server via ODBC.

When I look at the Date Time Feild in the Database it is a Sting Value with the following format:

2004-06-08 17:09:47.202 I need to convert this into a DateTime Value..

When I try to apply the formula: DateTimeValue({activitylog.datetimestamp}) I receive no syntax errors. However when I try to refresh the report I get an error BAD DATE TIME FORMAT STRING.

Does anyone have any solutions?
 
i believe the .202 is causing your problem.
I used your value of 2004-06-08 17:09:47.202 and received the same error as you.
I removed the .202 and it worked correctly.

I would suggest, if possible, something like the following:

//initialize variables
stringvar dtm;
numvervar strdtm;

//calculate location of "." in your field
strdtm := instr({YourTable.YourField},".");

//keep everything to the left of the "."
dtm := (left({YourTable.YourField},strdtm-1));

//convert the dtm variable to a datetime
datetimevalue(dtm);

 
OUTSTANDING! Worked like a charm.. my first thought was to trim off the millisecods as well but couldnt figure out the proper syntax to do so.. Thank you so much for your help.



Regards,

WiZoRioT.

 
Just as an FYI I was able to use the following method as well

datetimevalue(left({yourtable.yourfeild},19))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top