cancel
Showing results for 
Search instead for 
Did you mean: 

How to Convert String to datetime format

Former Member
0 Kudos

Hi Friend

I have a String like 20071212 that I want to convert to datetime format.

I have converted it like 2007-12-12T00:00:00. but that is string type. I want it as a Datetime format.

How can I do this

Thanks

Siddhartha P

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Siddhartha,

After playing around a bit, I found that if you take the date string and apply the datetoxmlformat function you can then assign the result to a property of datetime and the result is sql data type 93 (datetime). Hope this helps.

Kind Regards,

Diana Hoppe

0 Kudos

Siddhartha,

In BLS use the datetoxmlformat function like this...

datetoxmlformat("20071212", "yyyyMMdd")

Which is what you have probably done; the actual datatype is specified in the XML. The actual SQLDataType is in the XML column declaration as an attribute, with a value of 93. You probably have it defined as type 1 which is a string.

Please refer to the help documentation for more details...

Sam

Former Member
0 Kudos

Hi Sam

I have go through the help document for that function that you have written. but it takes input as datetime. and here i have string so it is giving me error.

Thanks

Siddhartha P

0 Kudos

Siddhartha,

datetoxmlformat("20061212", "yyyyMMdd") works...it takes a datestring and format as it's inputs. Make sure you are looking at the correct function.

Sam

Former Member
0 Kudos

" I have converted it like 2007-12-12T00:00:00. but that is string type. I want it as a Datetime format"

The type that you've mentioned above is not string but the dateTime representation in XML . I think you have done the correct conversion but somehow getting confused with the representation.

Moreover the function Sam's mentioned would get you the same result as well.You say you get an error, where? when?Is it when you use the function Sam's mentioned or anywhere else?Give the details.