conversion
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
conversion
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
inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
can anyone tell me what's wrong in this expression.
Thanks
Re: conversion
TRY thishondaccord94 wrote: inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
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
- prasad
Re: conversion
I think you need %yyyy instead of %YYYY. From the online Help :hondaccord94 wrote: inputDate [:timestamp] = StringToTimestamp(string(OpenDate)[%YYYY-%mm-%dd-%hh.%nn.%ss.6](OpenDate))
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.
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:
HTH,
Brad.
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)
Brad.
Try this instead (and see the last posting as well). I am assuming WORK_DATE is your new field and workdate is the old:srividhya wrote: WORK_DATE [:date] = date_from_string(workdate)[%yy-%mm-%dd]
Code: Select all
WORK_DATE:date = date_from_string[%yy-%mm-%dd](workdate)
-
- Participant
- Posts: 46
- Joined: Tue Aug 10, 2004 11:07 am
- Location: Mclean VA
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:
HTH,Code: Select all
myTmsp:timestamp[microseconds] = timestamp_from_string [%yyyy-%mm-%dd %hh:%nn:%ss.6] (datetimeString)
Brad.