Page 1 of 2

Date to Timestamp

Posted: Sun Apr 15, 2012 7:57 pm
by pavan_test
Hello,

I have source where the date is coming in the format 04/05/2012

can somone please tell me how do I convert this date to timestamp.

Thanks
Pavan

Re: Date to Timestamp

Posted: Sun Apr 15, 2012 8:25 pm
by SURA
Which format are you expecting?

DS User

Re: Date to Timestamp

Posted: Sun Apr 15, 2012 8:35 pm
by nbalegar
You can use DateToString() by specifying the format and again convert back the result to StringToTimestamp().

Posted: Sun Apr 15, 2012 9:20 pm
by jwiles
There is always the TimestampFromDateTime() transformer function

Posted: Sun Apr 15, 2012 9:44 pm
by chulett
First confirm for us the data type of this incoming 'date'... is it indeed a date or is it a string in that format? I suspect the latter as real dates have no 'format'.

Date To Timestamp

Posted: Mon Apr 16, 2012 9:27 am
by pavan_test
The incoming date format is : 04/05/2012

I wish to convert to Timestamp. (add zeros to the end is also fine)

Thanks
Pavan

Posted: Mon Apr 16, 2012 10:16 am
by chulett
Sorry, but that does not answer my question at all.

Date To Timestamp

Posted: Mon Apr 16, 2012 11:30 am
by pavan_test
The data type is date

Thanks
Pavan

Posted: Mon Apr 16, 2012 1:10 pm
by mobashshar
Use TimestampFromDateTime(ink_InputDate,"00:00:00")

Date To Timestamp

Posted: Mon Apr 16, 2012 1:36 pm
by pavan_test
The data is coming in the form of a string not date. I apologize for my previous posting.

I tried with TimestampFromDateTime and it is not working.

APT_CombinedOperatorController(1),1: Data string '03/23/2012' does not match format '%yyyy-%mm-%dd': the value for tag %yyyy has fewer characters than expected.

Thanks
Pavan

Posted: Mon Apr 16, 2012 1:38 pm
by chulett
StringToTimestamp().

Date To Timestamp

Posted: Mon Apr 16, 2012 1:52 pm
by pavan_test
When I tried the StringToTimestamp, I am getting this error message,

APT_CombinedOperatorController(1),0: Data string '03/10/201200:00:00' does not match format '%yyyy-%mm-%dd %hh:%nn:%ss': the value for tag %yyyy has fewer characters than expected.

StringToTimestamp(DateToString(DSLink2.da,"%yyyy-%mm-%dd") : ' 00:00:00',"%yyyy-%mm-%dd %hh:%nn:%ss")


the data from the source is string and i find thi: 04/13/2012

Thanks
Pavan
Thanks
Pavan

Posted: Mon Apr 16, 2012 2:15 pm
by mobashshar
Use this

TimestampFromDateTime(StringToDate(lnk_Date.Date,"%mm/%dd/%yyyy"),"00:00:00")

Posted: Mon Apr 16, 2012 2:20 pm
by jwiles
So, what is the format of your incoming date string (using the format specifiers, not an actual date)? Does it match the format "%yyyy-%mm-%dd"?

TimestampFromDateTime() didn't work for you probably because you haven't converted your incoming string into a date datatype. DataStage attempted to do that for you, couldn't and clearly gave you the reason why in the error message.

DateToString() is inappropriate within your StringToTimestamp() call because you ALREADY have a string for the date...why do you feel the need to convert a string from a Date to a String?. You're almost there---concatenate your date and time strings together and provide the correct format to the function. Date/Time format strings have been <a href="http://publib.boulder.ibm.com/infocente ... umented</a> for years...a brief search in the product documentation and you can find it :)

Regards,

Date To Timestamp

Posted: Mon Apr 16, 2012 2:34 pm
by pavan_test
This works

TimestampFromDateTime(StringToDate(lnk_Date.Date,"%mm/%dd/%yyyy"),"00:00:00")

Thanks
Pavan