- Posts: 568
- Thank you received: 72
Convert String to Time
- bruce.gibbins
- Topic Author
- Offline
- Platinum Member
-
Less
More
5 years 3 months ago #18207
by bruce.gibbins
Convert String to Time was created by bruce.gibbins
Hi
I have a READER column that is a String 24Hr time in a format of HHMM (Hour Minutes) eg. 1415 = 2:15PM
I need to get this into a TIME data type in SQL Server table.
There is no date part as that is being sent in a separate READER column and stored in a separate table column
I have tried various things but the closest I get generates an error. I am assuming I need to put a formatter in the transformer but Date Format and Reformat Date do not have a simple time reformatter that I can
Can't apply format YYYY-MM-DD HH:NN:SS.FFF for field Time(TIME) value 4:35:00 P
thanks in advance
I have a READER column that is a String 24Hr time in a format of HHMM (Hour Minutes) eg. 1415 = 2:15PM
I need to get this into a TIME data type in SQL Server table.
There is no date part as that is being sent in a separate READER column and stored in a separate table column
I have tried various things but the closest I get generates an error. I am assuming I need to put a formatter in the transformer but Date Format and Reformat Date do not have a simple time reformatter that I can
Can't apply format YYYY-MM-DD HH:NN:SS.FFF for field Time(TIME) value 4:35:00 P
thanks in advance
Please Log in or Create an account to join the conversation.
5 years 2 months ago #18233
by DeanCovey
Replied by DeanCovey on topic Convert String to Time
Interesting puzzle. I just spit balling. Maybe you need to take the string and convert to a number then perform some math then date reformat.
Please Log in or Create an account to join the conversation.
5 years 2 months ago - 5 years 2 months ago #18234
by DeanCovey
Replied by DeanCovey on topic Convert String to Time
Perhaps another way to go is to load the string into a varchar field in SQL. Then create a stored procedure to the update a time field based of that varchar.
Last edit: 5 years 2 months ago by DeanCovey.
Please Log in or Create an account to join the conversation.
- bruce.gibbins
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 568
- Thank you received: 72
5 years 2 months ago #18240
by bruce.gibbins
Replied by bruce.gibbins on topic Convert String to Time
Thanks Dean. Both solutions would be possible (I think) but seems to bring some complexity into the foreground that I was hoping to avoid. I am wondering as I have not experimented yet if t is possible to create a full date time string but use a zero date (eg. "0000-00-00 HH:MM:00.000") filling in HH:MM from the time string. I suspect SQL Server will baulk at an invalid date before realising it only needs the time component.
Please Log in or Create an account to join the conversation.
5 years 2 months ago #18241
by DeanCovey
Replied by DeanCovey on topic Convert String to Time
That could be an interesting way to go too. To your point, you could get a few hours in experimenting. If you go with letting SQL do the work, you'll be able to find resources online.
Please Log in or Create an account to join the conversation.
5 years 2 months ago #18243
by Maria
Replied by Maria on topic Convert String to Time
Hello.
We have reproduced the problem and currently looking at it.
We have reproduced the problem and currently looking at it.
The following user(s) said Thank You: bruce.gibbins
Please Log in or Create an account to join the conversation.