256
Views
8
Comments
Solved
In SQL Widget how to convert date time to time
Application Type
Reactive

I want to convert datetime field to time in sql widget? I tried sql query but couldn't

could you help me out.


select cast("Datetime column" as time) as Ltime

UserImage.jpg
Githiyon J
Solution

Thank you Ravi :)


2022-08-03 04-32-50
Ravi Punjwani

Hi Githiyon,

Give this a try with this one. You don't need any cast, just the receiving type should be Time. Outsystems will internally convert the DateTime field into Time by itself.


UserImage.jpg
Githiyon J
Solution

Thank you Ravi :)


2022-08-03 04-32-50
Ravi Punjwani

Glad it worked for you. It seems you marked the comment reply as Solution on the post instead of the actual solution :)

UserImage.jpg
vikas sharma
Champion

Hi,

I think you just need to make little changes in this, all other is okay..

SQL Server 2008:

SELECT cast(AttDate as time) [time]FROM yourtable

Earlier versions:

SELECT convert(char(5), AttDate, 108) [time]FROM yourtable

UserImage.jpg
Githiyon J

I tried this one in sql widget but it's not working

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Wouldn't the CONVERT be wrong if Time is in the output since it produces a Text? I'd say just CONVERT(time, AttDate)?

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

"Not working" is not a good description of any problem. You need to describe what exactly you did and what result you got. Also, if possible, share a module so we can take a look.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Githiyon,

First, you do not need to name columns, so the "as Ltime" part is not needed. Secondly, if you have a Time attribute in your output structure, OutSystems will convert the Date Time to Time automatically, so no need to cast inside the SQL. Thirdly, the cast seems valid, what exactly goes wrong with this?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.