conversion

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
hondaccord94
Participant
Posts: 46
Joined: Tue Aug 10, 2004 11:07 am
Location: Mclean VA

conversion

Post by hondaccord94 »

I am trying to use modify stage to convert the string to timestamp and I have specified in the modify stage like this
inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
can anyone tell me what's wrong in this expression.

Thanks
srividhya
Participant
Posts: 42
Joined: Tue May 31, 2005 10:11 am

Post by srividhya »

Hi
Iam also getting the same error,
i tried all the ways -no use
sri
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Re: conversion

Post by ukyrvd »

hondaccord94 wrote: inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
TRY this

inputDate [:timestamp] = timestamp_from_string[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate)

Make sure your input string actually has that format!!
thank you
- prasad
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

srividhya wrote:Hi
Iam also getting the same error,
i tried all the ways -no use
sri
Hi,
can you please be specific what what error you are seeing?
thank you
- prasad
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Re: conversion

Post by bcarlson »

hondaccord94 wrote: inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
I think you need %yyyy instead of %YYYY. From the online Help :
Format String

Date, Time, and Timestamp functions that take a format string (e.g. timetostring(time, stringformat)) need specific formats.

For a date, the format components are:

%dd two digit day

%mm two digit month

%yy two digit year (from 1900)

%year_cutoffyy two digit year from year_cutoff (e.g. %2000yy)

%yyyy four digit year

%ddd three digit day of the year

The default format is %yyyy-%mm-%dd

For a time, the format components are:

%hh two digit hour

%nn two digit minutes

%ss two digit seconds

The default is %hh:%nn:%ss, or, if extended to include microseconds, %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to.

A timestamp can include the components for date and time above. The default format is %yyyy-%mm-%dd %hh:%nn:%ss, or, if extended to include microseconds, %yyyy-%mm-%dd %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to.
srividhya
Participant
Posts: 42
Joined: Tue May 31, 2005 10:11 am

Post by srividhya »

Hi
my error is
main_program: Error parsing modify adapter: Error in binding: Error in destination field selector: Expected integer, got: ":"
Expected destination field selector, got: ")"; input:
WORK_DATE [:date] = date_from_string(workdate)[%yy-%mm-%dd]
;

same for timestamp also

Thanks
Sri
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

The problem is 2-fold. 1) wrong function, and 2) wrong format for function call.

The function you need is timestamp_from_string, not StringToTimestamp. I believe the latter is used in Transforms, not Modify Stages.

The format is as follows:

newfield:timestamp[microseconds] = timestamp_from_string[format](oldfield)

In the following example, I have an input string field called datetimeString, and am creating a new timestamp field called myTmsp:

Code: Select all

myTmsp:timestamp[microseconds] = timestamp_from_string [%yyyy-%mm-%dd %hh:%nn:%ss.6] (datetimeString)
HTH,

Brad.
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post by bcarlson »

srividhya wrote: WORK_DATE [:date] = date_from_string(workdate)[%yy-%mm-%dd]
Try this instead (and see the last posting as well). I am assuming WORK_DATE is your new field and workdate is the old:

Code: Select all

WORK_DATE:date = date_from_string[%yy-%mm-%dd](workdate)
Brad.
hondaccord94
Participant
Posts: 46
Joined: Tue Aug 10, 2004 11:07 am
Location: Mclean VA

Post by hondaccord94 »

Thank you ...
bcarlson wrote:The problem is 2-fold. 1) wrong function, and 2) wrong format for function call.

The function you need is timestamp_from_string, not StringToTimestamp. I believe the latter is used in Transforms, not Modify Stages.

The format is as follows:

newfield:timestamp[microseconds] = timestamp_from_string[format](oldfield)

In the following example, I have an input string field called datetimeString, and am creating a new timestamp field called myTmsp:

Code: Select all

myTmsp:timestamp[microseconds] = timestamp_from_string [%yyyy-%mm-%dd %hh:%nn:%ss.6] (datetimeString)
HTH,

Brad.
Post Reply