cancel
Showing results for 
Search instead for 
Did you mean: 

get date/time type items as string type using 'Data - OLEDB'

sumire
Level 9

Hello,

I want to retrieve a DB table using "Data - OLEDB".
In that case, I want to get date/time type items as string type.
I wrote it like this:

cast(startdatesime as Char) as startdatetime

but it gives me an error.
If I just write "startdatetime" and get it as a date/time type, I can get it successfully without error.
Please let me know how to write this.

Thank you for all your help.

------------------------------
Mitsuko
Asia/Tokyo
------------------------------
4 REPLIES 4

John__Carter
Staff
Staff

Try String instead of Char

Hello @John__Carter ,

Thank you for your reply.
I tried, but got error "Type String is not a defined system type.".

 

------------------------------
Mitsuko
Asia/Tokyo
------------------------------

Asilarow
MVP

 

This should give you the desired result:

cast(startdatetime as nvarchar(max)) as startdatetime

 

 

Andrzej Silarow

Hello @Asilarow ,

Thank you for your reply.
I took your advice and described it this way:

CONVERT(NVARCHAR(max), startdatetime, 120) as startdatetime

and it worked fine. Thanks.

 

------------------------------
Mitsuko
Asia/Tokyo
------------------------------