Non-Padded Timestamp Format

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
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Non-Padded Timestamp Format

Post by eli.nawas_AUS »

I have some timestamps that are formatted with nonpadded month, day, and hour fields ('%m/%d/%yyyy %h:%nn') in the output stage, but are being printed out with padded fields ('03/04/2013 00:00') in the file. Is this expected behavior?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How are they declared in the output Sequential File stage - as a string or as a timestamp?
-craig

"You can never have too many knives" -- Logan Nine Fingers
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

As timestamp.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Which is why you are getting the default formatting in the file. If you really want control over it, declare the output field as a string and then use TimestampToString() to get the specific external format you are looking for. That or don't worry about it. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

I am not getting the default, I am getting a non-default string that matches the string I expected except for the padding. The default string would be '%yyyy-%mm-%dd %hh:%nn:%ss'. The output format is specified in the output Sequential File stage, so it should output the value correctly.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK, fine... "default" was a poor choice of word on my part as I wasn't referring to an ANSI standard timestamp. If you've actually specified that formatting for the field in the Sequential File stage and it's not respecting it then perhaps it is a bug. Unless someone has some advice on a different format string to try, I would suggest asking your official support provider.

What version are you on, by the way?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

I seem to recall some ancient 8x documentation mentioning that those variable formats only work with the import operator (read). Check current documentation to see if that restriction still applies. You may have to go with Craig's suggestion if the export operator doesn't support the variable formats.

Mike
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

I am on version 9.1.0.0 according to the Help page.

The TimestampToString() function is not effective, I see the same problem:

TimestampToString(lnk_src.estimate_start_date,"%m/%d/%yyyy %h:%nn")

"03/09/2013 00:00"
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well, that sucks. According to the documentation what Mike thought turns out to still be true - those "variable width" time formats are only valid for the import operator.

"Where indicated the tags can represent variable-fields on import, export, or both. Variable-width date elements can omit leading zeroes without causing errors."

While some of the Date formats are valid for export, it would appear that none of the time ones are... which strikes me as odd. :? However, still seems like that shouldn't matter when using those formats in a conversion function like TimestampToString. Just to be anal, you did change your output field in the flat file to a string, yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

you can remove the padding with an if condition and field function.
StageVariable :
svMnth : field(lnk_src.estimate_start_date,'/',1)
svMnthNP: if left(svMnth,1) = 0 then right(svMnth,1) else svMnth
svDay : field(lnk_src.estimate_start_date,'/',2)
svDayNP: if left(svDay,1) = 0 then right(svDay,1) else svDay
svYear : field(field(lnk_src.estimate_start_date,'/',3),' ',1)
svHour : field(field(lnk_src.estimate_start_date,' ',2),':',1)
svHourNP: if left(svHour,1) = 0 then right(svHour,1) else svHour
svNN : field(lnk_src.estimate_start_date,':',2)
svNNP: if left(svNN,1) = 0 then right(svNN,1) else svNN
svString :svMonthNP:'/':svDayNP:'/':svYear:' ':svHourNP:':':svNNP
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or we could just work on finding a proper solution.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Out of curiosity, I did a little experimenting. It does seem like the variable-width formats are limited to the import operator. Transform functions and the export operator seem to treat variable-width formats as if they were a fixed-width format.

That leaves me with these suggestions:
1) enhancement request to IBM
2) creative stage variable shenanigans
3) custom parallel routine
4) buildop
5) Oconv in a server shared container

Mike
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Oh...and maybe

6) some awk/sed magic with the sequential file filter option

Mike
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... it seems we already have the shenanigans. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply