Windows File Date Time Attributes

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ianm
Charter Member
Charter Member
Posts: 15
Joined: Thu Sep 16, 2004 6:13 am

Windows File Date Time Attributes

Post by ianm »

How can I get the Date and Time Attributes of a Windows file ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I usually cheat and do a DOS shell command of "DIR" (or UNIX "ls -alk")and manually parse the resultant output string. You can wrap up that logic into a routine if you wish. The method to use depends upon where in DataStage you want to use the time & date attributes.
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Post by nkln@you »

ArnDW , can u pls elaborate on how to execute this dos statement in DataStage.
Aim high
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

nlkn - I have attached some sample code to do this. You will need to add some error checking and might need to change the format around depending upon your system's locale settings.

Code: Select all

Rem **************************************************************************************
Rem ** Routine to return the Date & Time of a DOS file as format "DD-MM-YYYY HH:MM:SS"  **
Rem ** The single lines of the program can be combined for efficiency, they have been   **
Rem ** separated for clarity. The date format that is output by dos is installation     **
Rem ** dependant, on my system it displays as MDY but that changes according to Windows **
Rem ** locale settings.                                                                 **
Rem ** Routine input parameter is "FileName" and needs the fully qualified DOS pathname **
Rem ** to the file.                                                                     **
Rem **************************************************************************************
CALL DSExecute("NT","DIR ":FileName,StringOutput,ErrorCode) ;** Get the DOS info
TempString = TRIM(StringOutput<6>)                          ;** the 6th line has the details
WorkDate   = ICONV(FIELD(TempString," ",1),"D4/MDY")        ;** convert date to internal fmt
WorkTime   = ICONV(FIELD(TempString," ",2),"MTS")           ;** convert time to internal fmt
Ans        = OCONV(WorkDate,"D4-DMY[2,2,4]")                ;** Create output date part of string
Ans        := " ":OCONV(WorkTime,"MTS")                     ;** Create output time part of string
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're prepared to write a Routine, you can use the STATUS statement to retrieve lots of information about a file.

You can find sample code here for retrieving some attributes. Read about the STATUS statement in the DataStage BASIC manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply