Hi,
I am trying to extract time part from a column whose data type is Date. For example my sample data is "1/1/1970 10:31:00 PM" and I want to take only "10:31:00 PM". My source table column is Date & target table column is also Date. I have tried it with DSTransform (TIMESTAMP.TO.DATE) but failed.
Thanks,
Bhaskar
extracting time from date
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 67
- Joined: Thu Apr 06, 2006 7:13 am
extracting time from date
Bhaskar Jha
Just use the substring function, use RIGHT(In.ColumnName,11) since your string looks like it has a variable length date portion.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 232
- Joined: Fri Sep 30, 2005 4:52 am
- Contact:
With that particular format, I doubt either portion will be of a fixed length. If that's the case, I'd use the FIELD function to split it at the first whitespace:
From memory. Otherwise, you could go with Arnd's solution.
Code: Select all
Field(In.ColumnName," ",2,2)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Craig - good thought, the function to use is
(although yours will work in this instance because there are no trailing spaces)Field(In.ColumnName," ",2,1)
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
You are, of course, correct. I'm just so used to European (or military) time that the AM/PM text completed zipped by me . I think the FIELD function is a better way to go in any case, since it is more robust than using straightforward positional values.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 67
- Joined: Thu Apr 06, 2006 7:13 am