Date to Timestamp
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date to Timestamp
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
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
Which format are you expecting?
DS User
DS User
Re: Date to Timestamp
You can use DateToString() by specifying the format and again convert back the result to StringToTimestamp().
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date To Timestamp
The incoming date format is : 04/05/2012
I wish to convert to Timestamp. (add zeros to the end is also fine)
Thanks
Pavan
I wish to convert to Timestamp. (add zeros to the end is also fine)
Thanks
Pavan
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date To Timestamp
The data type is date
Thanks
Pavan
Thanks
Pavan
-
- Participant
- Posts: 91
- Joined: Wed Apr 20, 2005 7:59 pm
- Location: U.S.
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date To Timestamp
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
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
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date To Timestamp
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
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
-
- Participant
- Posts: 91
- Joined: Wed Apr 20, 2005 7:59 pm
- Location: U.S.
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![Smile :)](./images/smilies/icon_smile.gif)
Regards,
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
![Smile :)](./images/smilies/icon_smile.gif)
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
-
- Premium Member
- Posts: 263
- Joined: Fri Sep 23, 2005 6:49 am
Date To Timestamp
This works
TimestampFromDateTime(StringToDate(lnk_Date.Date,"%mm/%dd/%yyyy"),"00:00:00")
Thanks
Pavan
TimestampFromDateTime(StringToDate(lnk_Date.Date,"%mm/%dd/%yyyy"),"00:00:00")
Thanks
Pavan