![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Extract from Date Topic Summary: How to extract Day, Month and year Created On: 19-Nov-2008 13:29 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hello All,
How do I extract the date, month and year from a given date by not knowing the format of it? Thanks & Regards Irfaan |
|
![]() |
|
![]() |
|
I don't believe your question is specific enough. Any given date should be of type Date.
Are you trying to convert a string to a Date or extract strings from a Date or strings from a string? ------------------------- Kevin Murphy http://www.baselinesinc.com |
|
![]() |
|
![]() |
|
Look Here:
|
|
![]() |
|
![]() |
|
Hi
I want to extract the day, month and year seperately from a given date. For example, if the date is "19-Nov-2008" I want to get the day as 19, month as Nov and year as 2008. The logic should be very general that it shld give the same result irrespective of the date format. For example, if the date was in format 19/11/2008 or 2008-11-19 or any standard date formats. Is there a way? Thanks & Regards Irfaan |
|
![]() |
|
![]() |
|
If your date string has the content 08/08/08, what is the date then? Might be that the first 8 is the year, or the last. But if the last is the year, is the beginning in the (American) format MM/dd or dd/MM?
Thus there can be no general method for parsing the date from a date string. In DOORS it is better to use Date variables, and if you have to transfer dates as string then agree to some strict format, e.g. http://en.wikipedia.org/wiki/ISO_8601 . ------------------------- Pekka.Makinen@softqa.fi SoftQA Oy -http://www.softqa.fi/ Edited: 19-Nov-2008 at 17:24 by Pekka Mäkinen |
|
![]() |
|
![]() |
|
There is probably a better way, but I use the attached function to do this sort of work. The problem arises when the 'Date' has seconds defined, in which case converting it to a string looks like "'09/08/04 10:52:32". Once that's detected, you strip off the seconds part "10:52:32" leaving "09/08/04", then convert that to a Date.
That date is then converted to a string and looks like "'08 September 2004", which is then parsed into its constituent parts. See the attached function I use. It will not work for you as-is. You will need to write your own 'fGetOffset' which finds the location of a string inside another string (you would probably use the 'matches' function). Function 'fIsSubStr (is SubString) is simply fGetOffset returned as a boolean. My function 'fDateOf' is rather complicated, but you can probably duplicate it like this: noError() datOut = InDate lastError() - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Extract from Date
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.